<!-- Start of markdown source --> Overview ------------ This workshop provides an introduction to the Code Composer Studio Theia integrated development environment leveraging C2000 C29x Academy. It will cover how to get started using an F29H85x controlSOM. [[b Note: This workshop can be used to learn about all Theia-based IDE, including CCS Theia and CCS 20. ]] Requirements ------------ Software: * [Code Composer Studio Theia v1.5.1](https://www.ti.com/tool/download/CCSTUDIO-THEIA) or [Code Composer Studio v20.x](https://www.ti.com/tool/CCSTUDIO) or greater. * [F29H85x SDK](https://www.ti.com/tool/F29-SDK) which can be installed as a step of Lab 1. * [C29x Academy](https://dev.ti.com/tirex/global?id=C29X-ACADEMY) is necessary for Lab 1. Hardware * F29H85x, F29H85x controlSOM, or F29H85x LaunchPad * Internet access Lab 1: Importing, Editing, and Running an Example Project --------------- This lab will go over importing an example project from the F29H85x SDK, making some edits to modify the program's functionality, and flashing the program to the target (the F29H85x controlSOM) to run the program. Please refer to the [Timer LED Lab](https://dev.ti.com/tirex/local?id=source_c2000_academy_labs_c29_labs_c29_timer_lab&packageId=C29X-ACADEMY) in C29x Academy for step-by-step instructions as well as the complete software solution. [[b Note: For further code development support, browse through example projects in the F29H85x SDK. There are simple projects which utilize hardware resources such as the ADC, I2C, SPI, etc. ]] Lab 2: Basic Debug Concepts --------------- This lab will cover the basics of debugging, using [the modified **timer_academy_lab.c** code from Lab 1](#lab-1:-importing,-editing,-and-running-an-example-project). Specific tools and concepts that are covered are: * Breakpoints * Watchpoints * Watch * Debug view * Disassembly view * Other Views ### Breakpoints Breakpoints are specific points that can be set in the code, where the program is to halt execution. Once halted, the values in registers/memory/etc. can be inspected to gain a deeper understanding of the program execution. This is very useful when debugging. [[y Hardware Breakpoints A hardware breakpoint is required when setting a breakpoint in Flash. The number of available hardware breakpoint resources varies per device. The F29H85x supports up to seven simultaneous hardware breakpoints. ]] 1. If your F29H85x controlSOM is currently running, ensure you are in the **Debug** view and **Pause** it. Otherwise, click on **Run &rarr; Debug Project(...)** to flash the program to the target and pause it. 2. Click on the **Breakpoints** panel under the **Debug** view to expand it. There should be no breakpoints to start. 3. While staying in the **Debug** view, in **timer_academy_lab.c**, scroll to the definition of the **INT_myCPUTIMER0_ISR()** function, and click on the margin to the left of the line number. This will insert a breakpoint that will halt program execution whenever it reaches this point in the code. ![Inserting a breakpoint](./images/theia-f29x-inserting-breakpoint.png) 4. Click **Run &rarr; Continue** to resume program execution on the controlSOM. Click the left button on the board, and note that the program has suspended due to the breakpoint. 5. By clicking **Run &rarr; Step Into** or **Run &rarr; Step Over** (or using the related buttons in the **Debug** view), the target will do the associated source step. Click **Run &rarr; Continue** to resume program execution. * **Step Into** steps to the next line of code, including stepping into a new function call. * **Step Over** steps to the next line of code in the current function, but will not step into a new function call. It will remain in the current function until it ends or returns. * **Step Out** steps out of the current function before it reaches its end, and suspends execution on the next statement of the calling function. 6. After you are finished with this part of the lab, in the **Breakpoints** panel, remove the breakpoint. You can also remove it by clicking the margin next to the line number in **timer_academy_lab.c**, where the breakpoint currently exists. ### Watchpoints A watchpoint is a type of hardware breakpoint that monitors activity on a memory address, for example where a variable's value is stored. 1. If your F29H85x controlSOM is currently running, ensure you are in the **Debug** view and **Pause** it. Otherwise, click on **Run &rarr; Debug Project(...)** to flash the program to the target and pause it. 2. Click **Run &rarr; New Breakpoint &rarr; Hardware Watchpoint**. This will open a dialog to add a new data breakpoint. 3. Set the **Address** to `&cpuTimer0IntCount`(the address of `cpuTimer0IntCount`) and **Access type** to **Write**, and click **OK**. This installs a watchpoint which will pause program execution on the target whenever the value of `cpuTimer0IntCount` is modified (whenever it is written to). ![Inserting a watchpoint](./images/theia_f29x_data-breakpoint.png) 4. A new breakpoint will be added under the **Breakpoints** panel under the **Debug** view. 5. Click **Run &rarr; Continue** to resume program execution on the controlSOM. Click the left button on the board, and note that the program has paused due to the data breakpoint. 6. Leave the data breakpoint set as it will be used in the next section. ### Watch The **Watch** view allows you to monitor the values of variables (local, global, static), C-valid expressions and even registers. The value of an expression may also be modified when the situation permits. 1. Ensure that the program is paused. In the **Debug** view, click on the **Watch** panel to expand it. Click on the `+` button and add `cpuTimer0IntCount` in **Expression to watch**. This will display the value of `cpuTimer0IntCount` whenever the program is paused. Resume the program and click the left button on the board again to pause the program and view the value of `cpuTimer0IntCount` change. 2. Click **Run &rarr; Continue** to resume program execution on the controlSOM. 3. Take note of the speed at which the LED lights are blinking. Click **Run &rarr; Pause** to pause the execution of the program. 4. In the **Watch** panel, mouse right-click on the `cpuTimer0IntCount` expression and click **Edit Expression**. Set the value to `10` and click **OK**. Click **Run &rarr; Continue** to resume program execution. The LED blinking rate should be noticeably slower. This is an example of modifying variable values through the **Watch** panel. ![Set cpuTimer0IntCount value](./images/theia_f29x_watch-set-value.png) 5. In the **Breakpoints** panel, remove the data breakpoint. The press the **Continuous Refresh** button on the toolbar. It is the third button from the left which looks like a continuous circle. This will update the expressions in the view continuously. If the device supports non-intrusive memory accesses (allow the debugger to access memory while the target is running), then the values can be updated while the target is still running. F29H85x supports non-intrusive memory accesses. Click the left button on the board periodically and note how the `cpuTimer0IntCount` expression will change as the button is pressed. 6. After you are finished with this part of the lab, in the **Watch** panel, remove the **cpuTimer0IntCount** expression. ### Debug View ### In addition to the target execution toolbar and providing information on **Breakpoints**, the **Debug** view also provides more information in the following collapsable views: * **Threads**: This view will show the current debug session and the status the CPU. * **Call Stack**: This view will provide the current call stack information for the program. * **Variables**: This view will display all local variables and related values. * **Watch**: This view allows you to add/view desired expression. For example, use the `+` button to add the global variable `cpuTimer0IntCount` to the list of watch expressions. * **Breakpoints**: This view allows you to view/enable/disable/remove breakpoints. ![Debug View](./images/theia_f29x_debug-view.png) ### Disassembly View 1. If your F29H85x controlSOM is currently running, ensure you can see the **Debug** view and that execution is **Paused**. Otherwise, click on **Run &rarr; Debug Project (...)** to flash the program to the target and pause it. 2. Click on **View &rarr; Disassembly** to open the **Disassembly** view. 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 yellow arrow(s). Symbols will be highlighted in green text. 3. You can enter in an address or symbol in the location box at the top of the **Disassembly** view to change the address that the view starts at. Enter **main** to display diassembly content starting from the **main** symbol. 4. Note the toolbar with button to **Refresh view**, **Goto current PC location**, **Assembly step-into**, and **Assembly step-over**. 5. To toggle source interleaving, bring up the context menu in the **Disassembly** view and select **Show source** in the context menu. This will interleave the source lines with the disassembly. Source lines will be highlighted in yellow text ![Disassembly view with show source](./images/theia_f29x_disassembly.png) ### Other Views Several other views are available under the **View** menu. Experiment with the various views such as: #### Register View The **Registers** view is used to display and edit the values of core and memory mapped (peripheral) registers. Click on **View &rarr; Register** to open the view. #### Memory View The **Memory** view is used to display and edit the values memory. Click on **View &rarr; Memory** to open the view. ### Summary Lab 1 covered using Code Composer Studio Theia to import an example project, modify it, and flash it to a target to run the program. Lab 2 provided information on the basics of using debug tools in Code Composer Studio Theia. <!-- End of markdown source --> <div id="footer"></div>