280 likes | 521 Views
MSP430 C Programming with CCS. TI MCU Software and Tools Ecosystem. Run-Time Software Easy-to-use, highly-portable Energia software O/S independent device support with TI- Ware software TI-RTOS : kernel, filesystem , USB, networking, drivers. Development Tools
E N D
TI MCU Software and Tools Ecosystem • Run-Time Software • Easy-to-use, highly-portable Energiasoftware • O/S independent device support with TI-Waresoftware • TI-RTOS: kernel, filesystem, USB, networking, drivers • Development Tools • CCStudio™Integrated Development Environment (IDE) • Optimizing compilers • Graphical coding (e.g. Grace) • Design Kits & EvalModules • Rich 3rd Party Support (e.g. IAR) • Support & Community • TI Design Network: off-the-shelf software, tools & services • Forums: http://e2e.ti.com • Wiki: processors.wiki.ti.com • Training: In-person and online Free code that runs on your system Tools that help you create your code Resources to help you help yourself Run-Time Software …
Development Tools for MSP430 • GCC*: CCSv6+ contains GNU GCC compilerMSPGCC was available prior to GNU GCC • CCSv6+ allows you to debug Energiaprojects using full debug toolset ULP...
ULP (Ultra-Low Power) Advisor Squeezing out every last nanoAmp • Checks your code against an MSP430 ULP Checklist • The ULP Advisor wiki includes a description of each rule, proposed remedies, code examples & links to related e2e online forum posts • ULP Advisor is FREE and is available as a plugin for CCS • Standalone command-line tool for use with other IDEs • Learn more at www.ti.com/ulpadvisor Write your code… Wiki provides details & remedies ULP Advisor finds areas for code improvement Grace...
CCS Functional Overview Compiler .asm .c Asm Link Debug .obj Edit .asm CCS is an IDE ... What does that mean?
CCS Functional Overview Compiler .asm .c Asm Link Debug .obj Edit .asm • Integrated Development Environment (IDE) based on Eclipse • Integrated “Debugger” and “Editor” – IDEEdit and Debug have the own “perspectives” (menus, windows) • Contains all development tools – compilers, TI-RTOS kernel and includes one target – the Simulator
CCS Functional Overview Compiler Standard Runtime Libraries .asm .lib .c Asm Link Debug .obj Edit .asm .out User.cmd .map • Integrated Development Environment (IDE) based on Eclipse • Integrated “Debugger” and “Editor” – IDEEdit and Debug have the own “perspectives” (menus, windows) • Contains all development tools – compilers, TI-RTOS kernel and includes one target – the Simulator
CCS Functional Overview Compiler Standard Runtime Libraries TI-RTOS Libraries .asm .lib .c Asm Link Debug .obj Edit .asm .out TI-RTOS Config (.cfg) User.cmd .map Bios.cmd • Integrated Development Environment (IDE) based on Eclipse • Integrated “Debugger” and “Editor” – IDEEdit and Debug have the own “perspectives” (menus, windows) • Contains all development tools – compilers, TI-RTOS kernel and includes one target – the Simulator
CCS Functional Overview Compiler Standard Runtime Libraries TI-RTOS Libraries TargetCfg File .asm .lib .c .ccxml Launch Pad Asm Link Debug .obj Edit .asm .out EVM TI-RTOS Config (.cfg) User.cmd .map Stand Alone Emulator (MSP430 FET) Bios.cmd • Integrated Development Environment (IDE) based on Eclipse • Integrated “Debugger” and “Editor” – IDEEdit and Debug have the own “perspectives” (menus, windows) • Contains all development tools – compilers, TI-RTOS kernel and includes one target – the Simulator
CCS GUI – EDIT Perspective Menus & Buttons • Specific actions related to EDIT’ing Perspectives • EDIT and DEBUG Project Explorer • Project(s) • Source Files Source EDIT’ing • Tabbed windows • Color-coded text Outline View • Declarations and functions If you click on the "Debug" perspective, the windows change to...
CCS GUI – DEBUG Perspective Connection Type • Specified in Target Cfg file • What options do users have when connecting to a target? • This window also provides a “call” stack Menus & Buttons • Related to DEBUG’ing • Play, Pause, Terminate DEBUG Windows • Watch Variables • Memory Browser • PC execution point • Console Window
Workspaces and Projects (GUI) Source PROJECT
Workspaces and Projects (GUI) WORKSPACE Source PROJECT Looking more closely at Projects and Workspaces...
Projects and Workspaces • Project • Source Files • Header Files • Library Files • Build/tool settings • Source Files • Code and Data • Header Files • Declarations Library Files • Project folder contains: • Build and tool settings (for usein managed MAKE projects) • Files can be linked to or reside in the project folder • Deleting a linked file from Project Explorer only deletes the link
Projects and Workspaces Project • Source Files • Header Files • Library Files • Build/tool settings Source Files • Code and Data Workspace • Project 1 • Project 2 • Project 3 • Settings/pref’s Header Files • Declarations Library Files • Workspace folder contains: • ‘Workspace’ is just a folder that keeps track of projects… along with IDE settings and preferences • Projects can reside in the workspace folder or be linked from elsewhere • Deleting a project from the Project Explorer only deletes the link • Project folder contains: • Build and tool settings (for usein managed MAKE projects) • Files can be linked to or reside in the project folder • Deleting a linked file from Project Explorer only deletes the link
Creating a New Project (CCSv6) File New CCS Project (in Edit perspective…) Select Device ConnectionHow target is connected to CCS (creates .ccxml file in project) Project Name Project TypeExecutable or Library Project Location• Default = workspace• Manual = anywhere you like Templates• No BIOS? Choose “Empty”• BIOS? Choose BIOS template Adding files to the project…
Adding Files to a Project • Users can ADD (copy or link) files into their project • SOURCE files are typically COPIED • LIBRARY files are typically LINKED (referenced) 1 2 3 Right-click on project and select: Select file(s) to add to the project: Select “Copy” or “Link” • COPY • Copies file from original location to project folder (two copies) • LINK • References (points to) source file in the original folder • You can select the “reference” point (default is project’s dir)
Compiler Build Options • Almost 100 compiler options let you tune your code’s performance, size, etc. • The following table lists the most commonly used options: • To make things easier, CCS creates two BUILD CONFIGURATIONS: • Debug (no optimization) which is great for LOGICAL debug • Release which is good for PERFORMANCE/Size • Users can create their own custom build configurations How do you CHANGE compiler build options or configurations?
Modifying Build Configurations • Right-click on the project and select Properties • Select the build configuration: Debug or Release • Then click “Processor Options” or any other category (like Optimization):
MSP430 C Data Types • Data are aligned to 16-bit address boundary (except where noted) • 8-bit values are stored in bits 0-7 of a register • 32- and 64-bit types require 2 and 4 registers, respectively
Example: Device Specific ‘Header’ Files • Below is an example of using the MSP430 ‘header’ files. • This example will be used in the upcoming lab exercise. It turns off the Watchdog Timer (WDT). We have to setup the WDT in every MSP430 program. (We explain why later.) • Device header file ( msp430f5529.h) Register bit-field symbols are found in ‘header’ file WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
Example: Device Specific ‘Header’ Files Which “build” tool allocates memory and assigns addresses to symbols in our program? • Below is an example of using the MSP430 ‘header’ files. • This example will be used in the upcoming lab exercise. It turns off the Watchdog Timer (WDT). We have to setup the WDT in every MSP430 program. (We explain why in Chapter 4 of the workshop.) • Device header file ( msp430f5529.h) Register bit-field symbols are found in ‘header’ file WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
Example: Device Specific ‘Header’ Files • Below is an example of using the MSP430 ‘header’ files. • This example will be used in the upcoming lab exercise. It turns off the Watchdog Timer (WDT). We have to setup the WDT in every MSP430 program. (We explain why in Chapter 4 of the workshop.) • Notice how “address” values (i.e. register locations) are found in the .cmd file, while all other symbol definitions are found in the .h file. • Device header file ( msp430f5529.h) Register bit-field symbols are found in ‘header’ file WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer • Device linker command file ( msp430f5529.cmd ) Symbols that represent register locations – which are effectively addresses – are found in the ‘linker’ command file
Intrinsics for MSP430 C Compiler • Compiler intrinsic functions are essentially “built-in” C functions • They usually provide access to underlying hardware features of a processor; often mapping closely to specific asm instructions • We will use some of these in today’s workshop:
Lab 2 – Creating CCS Projects • Lab 2a – Hello World • Create a new project • Build program, launch debugger, connect to target, and load your program • printf() to CCS console • Lab 2b – Blink the LED • Explore basic CCS debug functionality • Restart, Breakpoint, Single-step, Run-to-line • Lab 2c – Restore Demo to Flash • Import CCS project (for original demo) • Load program to device’s flash memory • Verify original demo program works • (Optional) Lab 2d • Create binary TXT file of your program • Use MSP430 Flasher to program original demo’s binary file to device’s flash Time: 45 minutes