NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
Watchpoints for Stellaris in CCS
Contents
Introduction[edit]
This page describes how to setup Hardware breakpoints, Watchpoints and Count Events in CCS v4, v5 and v6 for the Stellaris Cortex M3/M4F devices. Hardware breakpoints stop execution of the program. Hardware watchpoints allow you to halt when a read or write access is made to a data variable address. Count Event can be used to measure clock cycles between two points in the code. Since these are all implemented internally by the hardware and require on-chip analysis resources, there is usually a limit to the maximum number of events that can be enabled at one time.
Configure a Hardware Breakpoint[edit]
The steps below describe how to configure a hardware breakpoint in CCS.
- Configure CCS for a Stellaris target and launch a debug session.
- In the Debug Perspective, open the breakpoint dialog: View->Breakpoints.
- Use the pulldown to select Hardware Breakpoint.
- In the Location field, specify the address where the breakpoint should be set.
Alternately, if the code is programmed to Flash, double-clicking on a line of code in the editor will automatically set a hardware breakpoint.
Note: Stellaris devices are limited to 6 hardware breakpoints. If you try to set more than the allowed limit, the following message will appear
Also, by default the debugger sets breakpoints to halt at CIO and end of program, so two breakpoints will be used for this, allowing only 4 breakpoints to be available to the user. These breakpoints can be disabled by going into menu Run->Debug Configurations…, Target tab, and unchecking the boxes for “Halt at program termination” and “Enable CIO function use”.
Configure a Hardware Watchpoint[edit]
- Configure CCS for a Stellaris target and launch a debug session.
- In the Debug Perspective, open the breakpoint dialog: View->Breakpoints.
- Use the pulldown to select Hardware Watchpoint.
- In the Location field, specify the address that you want to watch and if it should stop on a read or write access. For eg, if you want to watch when a global variable named g_ulGPIOa is written to, you can specify &g_ulGPIOa for the Location and Write for the memory access.
- The watchpoint can be further customized, if needed, by right-clicking on the watchpoint and selecting Properties. From this dialog box you can:
Configure a Count Event[edit]
The Profile Clock on Cortex M3/M4F is disabled due to Hardware limitations. Hence the menu Run->Clock in CCS will be greyed out. However, a count event can still be configured and can provide clock cycles.
- Configure CCS for a Stellaris target and launch a debug session.
- In the Debug Perspective, open the breakpoint dialog: View->Breakpoints.
- Use the pulldown to select Count Event.
- Select the Event to Count as Clock Cycles.
- Enable a breakpoint in your code by double-clicking on the line in the source file. Select the Run icon. When the breakpoint is reached the Count Event will display the number of Clock Cycles.
- You can also set two breakpoints to count the number of cycles between two places in your code (useful to profile functions):
Enable the count event as shown above, then right-click on its entry in the Breakpoints view, select Properties and check the box marked Reset Count on Run. This will make the Event counter reset every time the processor is put to run, therefore allowing counting events within breakpoint boundaries.
- Set two breakpoints in your code
- Run to the first breakpoint. The Event counter will count the number of cycles up to this point in your code. You can disregard this number.
- Run to the second breakpoint. This time the Event count will show the number of cycles between the first and the second breakpoint.
Note: The number of CPU cycles can vary greatly depending on the type of memory the code is running from (Flash, RAM, external).
Profiler[edit]
The function profiler is not supported on Stellaris hardware. The CCS menu Run->Profile->Set up Profile Data Collection does not permit activation of function profiling. An alternate method is to use the Count Event as described above.
Function profiling is supported in the Cortex M3 core simulator included with CCS v4/v5.
Checking for stack overflow[edit]
A common issue causing software instability is stack overflow. When building a project the stack size is specified in the project linker options (or in the configuration file for DSP/BIOS projects). That corresponding size will be allocated for the stack by the linker. The linker will generate a symbol called __stack (two preceding underscores) that corresponds to the lowest address of the stack.
A hardware watchpoint can be used to monitor when __stack is written to, which will indicate that a stack overflow has occurred.
- Configure CCS for a Stellaris target and launch a debug session.
- In the Debug Perspective, open the breakpoint dialog: View->Breakpoints.
- Use the pulldown to select Hardware Watchpoint.
- For the Location, enter the symbol __stack. For the Access Type, select Memory Write. Now every time the CPU writes to that address it will halt.