#Overview
This workshop provides an introduction to the Code Composer Studio integrated development environment. It will cover how to get started using the environment on a C2000 LaunchPad.
This workshop uses projects from C2000Ware software package. If you are using ControlSuite instead, please refer to the workshop [here](https://software-dl.ti.com/ccs/esd/training/workshop/ccsv7/c2000/site/). The workshop using ControlSuite is written for F28027 Launchpad, but both workshops can be run on any C2000 Launchpad as long as you choose the appropriate project for your device.
#Requirements
**Software:**
- [Code Composer Studio v7.3](https://www.ti.com/tool/ccstudio) or greater
- With all **C2000 components** installed
**Hardware:**
- [F28379D LaunchPad (LAUNCHXL-F28379D)](https://www.ti.com/tool/launchxl-f28379D)
![](./images/launchxl-f28379d.jpg)
Connect the LaunchPad to the Computer via mini-USB cable
#LAB 1 - Getting Started
Key Objectives
- Import an example program that blinks the LED
- Start a debug session and load/flash the program to the target
- Run the program
Tools and Concepts Covered
- Eclipse Concepts (Workspace, Workbench, Perspectives, Views, Projects)
- Resource Explorer
- Importing/Building/Running an example project/program
##Launch Code Composer Studio (CCS) and Open Resource Explorer
1. Launch CCS with the Code Composer Studio desktop icon
2. Specify a location for your workspace when prompted. This is where your projects will be located. Use a path that does NOT use spaces or any non-alphanumeric characters, with the exception of the underscore character
3. Select **Browse Examples** in the **Getting Started** page
##Resource Explorer: Examples
Displays all example projects available under the **Resource Explorer**. This includes all available content on the remote TI server, in addition to any content you may have installed locally.
1. Select the device or board you are working with in the *Select a device or board* filter box in the top left corner. For this workshop, we select **F28379D**
2. Select the **Bitfield** examples under *Software -> C2000Ware -> English -> Devices -> F28379D -> Examples*
3. Click the **Download and install** icon. This will make a copy of the **C2000Ware** package that is on the Cloud onto your local machine. This is required to import any examples into your local CCS environment
![](./images/rex_download_1.png)
A prompt will appear, asking for confirmation. After agreeing to the prompt, the **C2000Ware** will start downloading. Once the download and installation to the local environment is completed, **C2000Ware** will appear in the Resource Explorer, highlighted with green arrows, indicating that it is available locally (offline) on your machine.
![](./images/rex_download_2.png)
4. Select the **timed_led_blink** example under *Software -> C2000Ware -> English -> Devices -> F28379D -> Examples ->Bitfield ->CPU1 * and click the **Import to IDE** icon
![](./images/import_1.png)
This will import the project into your workspace. The project will appear in the **Project Explorer** view if the import is successful
![](./images/import_2.png)
5. Select menu *Run -> Debug* to build/load/run the project. Alternatively you can click the bug button on the toolbar
Several actions are done automatically
- Prompt to save source files (if necessary)
- Build the project (incrementally)
- Start the debugger (CCS will switch to the **CCS Debug** perspective)
- Connect CCS to the target
- Load (flash) the program on the target
- Run to **main**
Don't want it to do all of the above at once? You can configure it to skip some steps (**Debugger Options**)
If a debug session for this device is being launched for first time, a dialog will prompt user to select which CPUs to load the program to. This dialog will appear if the device has multiple CPUs supported by the project
6. Uncheck the second entry **C28xx_CPU2** and click **OK**
![](./images/debug_launch_1.png)
CCS will switch to the CCS Debug perspective and be halted at main()
![](./images/debug_launch_2.png)
7. Select menu *Run -> Resume* or click the **Resume** button on the toolbar to run the program
Program will run and blink the red LED on the Launchpad
![](./images/f28379d_blinking.jpg)
8. Click the **Suspend** button on the toolbar to halt the program
9. Click the **Restart** button on the toolbar to restart the program
##Summary
In this lab we completed the following:
- Imported an example that blinks the LED from **C2000Ware** via the **Resource Explorer**
- Built and ran the example
#LAB 2 - Basic Debug Concepts
Key Objectives
- Learn the basics of debugging using the Blink LED example
- Basic Profiling
Tools and Concepts Covered
- Basic Debug Concepts
- Breakpoints/Watchpoints
- Profile Clock
##Breakpoints
[[b **NOTE:**
Both software breakpoints and hardware breakpoints are available for use. A hardware breakpoint uses debug resources on the device as compared to a software breakpoint which is typically an opcode replacement.
A hardware breakpoint is required when setting a breakpoint in Flash, while a software breakpoint can be used in RAM. While the number of software breakpoints available is practically limitless, the number of hardware breakpoints is typically small in number. C2000 devices support two hardware breakpoints.
]]
1. Go to menu *View -> Breakpoints* to open the **Breakpoints** view
2. Double-click in the left selection margin of the editor beside line 176 in LEDBlink.c. This will set a software breakpoint as the code is in RAM. An icon will appear in the selection margin indicating the location of the breakpoint. It will also be listed in the **Breakpoints** view
![](./images/breakpoint_1.png)
3. Click the **Resume** button. The program will halt at the breakpoint
4. Click **Resume** again a few times. Observe the red LED toggling during each run
5. Remove the breakpoint by selecting the breakpoint in the **Breakpoints** view and clicking the *Remove* button
![](./images/breakpoint_2.png)
6. Restart the program by going to menu *Run -> Restart* or clicking the **Restart** button in the Debug view
##Watchpoints
A watchpoint is a type of breakpoint that monitors activity on a memory address
1. In the **Breakpoints** view click the down arrow beside the *New Breakpoint* button and select **Hardware Watchpoint**
![](./images/watchpoint_1.png)
2. For Location, enter **CpuTimer0.InterruptCount** and for Memory, select **Write**. Click OK
![](./images/watchpoint_2.png)
3. In the **Breakpoints** view, right-click on the watchpoint and select Breakpoint Properties in the context menu
![](./images/watchpoint_3.png)
4. Modify the properties to match the settings shown below
- With Data: Yes
- Data Value: 0x20
![](./images/watchpoint_4.png)
Click OK to apply changes
This sets a watchpoint to halt the CPU when **CpuTimer0.InterruptCount** is written to with a value of **0x20**
5. In the editor view, go to line 176, highlight **CpuTimer0.InterruptCount**, right-click and select *Add Watch Expression...* in the context menu
![](./images/watchpoint_5.png)
This will add **CpuTimer0.InterruptCount** to the **Expressions view**
6. Click the **Resume** button to run the target. Wait until the program halts. Check the value of **CpuTimer0.InterruptCount** in the **Expressions** view when the program is halted. Note that it should be the same value that was entered in the *Value* field for the watchpoint properties, in this case 32 (0x20)
![](./images/watchpoint_6.png)
7. In the **Breakpoints** view, remove the watchpoint using the *Remove All Breakpoints* button
![](./images/watchpoint_7.png)
8. Restart the program by going to menu *Run -> Restart* or clicking the **Restart** button in the Debug view
##Profile Clock
The profile clock can be used to count clock cycles
1. Enable the clock by going to menu *Run -> Clock -> Enable*
![](./images/profile_1.png)
The clock will be displayed in the CCS status bar at the bottom right
2. Double-click in the left selection margin of the editor beside line 176 in LEDBlink.c to set a breakpoint
![](./images/profile_2.png)
3. Click the **Resume** button. The program will halt at the breakpoint. The Clock will show the number of cycles it took to execute from the beginning of main to current breakpoint (~30M cycles)
![](./images/profile_3.png)
4. Double-click on the Clock icon to reset the count to 0
![](./images/profile_5.png)
5. Click the **Resume** button again. The Clock will show the number of cycles to execute from the previous breakpoint to the current breakpoint (~30M cycles between each LED blink)
![](./images/profile_4.png)
6. Click the **Resume** button several times and note that the clock cycles increment by about 30M cycles each time
7. Disable the clock by going to menu *Run -> Clock -> Disable*
8. Remove the breakpoint by selecting the breakpoint in the **Breakpoints** view and clicking the *Remove* button
##Disassembly View
1. Restart the program by going to menu *Run -> Restart* or clicking the **Restart** button in the Debug view. The program will be at the start of main()
2. Open the **Disassembly** view by going to *View -> Disassembly*. By default it will show the disassembly of the current location in the code. The location of the Program Counter is indicated with a small blue arrow. You can enter in an address or symbol in the location box to change the address that disassembly starts at
3. Click the **Show Source** button in the **Dissassembly** view to toggle interleaving of source code with the assembly code
![](./images/disassembly_1.png)
##Other Views
Several other views are available under the View menu. Experiment with the various views
####Registers view
The Registers view is used to display and edit the values of core and memory mapped (peripheral) registers
![](./images/registers_1.png)
####Memory allocation view
The Memory Allocation view shows a graphical display of memory allocation
![](./images/memory_allocation_1.png)
##Summary
In this lab we completed the following:
- Covered the basics of Debugging
- Learned how to use breakpoints and watchpoints
- Learned how to count cycles using profile clock
- Became familiar with several debug views