Realtime Debug Embedded Development Tools What is Realtime
Real-time Debug Embedded Development Tools
What is Real-time Debug? • Stop Mode Debug (traditional debugging) – require the processor to be completely halted to access memory and registers – stops all threads and prevents interrupts from being handled • Stop Mode can be used as long as system/application does not have real-time constraints, but is very undesirable for real-time applications • Real-time Mode Debug enables programmers to: – examine and modify contents of memory/register locations while CPU is running and executing code – halt/debug application while allowing user specified time critical interrupts to be serviced without interference CCS APPS • Real-time debug capabilities vary by device and are supported via different methods
Real-time Debug capabilities • Access to memory while the processor is running – Supported on Tiva, Stellaris, Hercules, C 28 x, C 66 x, C 64 x, C 55 x – On ARM it is enabled through the DAP (Debug Access Port) • DAP is part of the ARM emulation logic and enables the debugger to access memory of the device without requiring the processor to enter the debug state – On DSP/28 x it is enabled via ICEMaker hardware – Also possible on Cortex A devices but is not recommended when the MMU is in use (will always show physical memory and not virtual) • Access to registers while the processor is running – Supported on C 28 x, C 66 x, C 64 x, C 55 x – Enabled through hardware (ICEMaker) • Service interrupts while the processor is halted CCS APPS – Supported on C 28 x, C 66 x, C 64 x, C 55 x – Enabled through hardware (ICEMaker)
Real-time Mode: Polite and Rude • Memory accesses and halts issued from the debugger can be blocked – For example, when in a critical section of code setting the DBGM (Debug Mask) bit in status/control register will block accesses • Hardware or application can set DBGM bit – In some devices hardware sets it automatically when any interrupt is taken • In Polite real-time mode (default when real-time mode is enabled) – DBGM settings are respected by debugger – Debugger will not stall the processor to make memory accesses, but rather will wait for processor to get into non-critical section of code before making the access • In Rude real-time mode CCS APPS – DBGM settings are ignored by debugger and accesses are made anyway – Allows for error recovery if application sets these bits and then hangs
Real-time Interrupts • When halted in Stop mode, all interrupts are blocked • When halted in Real-time mode, time critical interrupts can continue to be serviced – The Debug Interrupt Enable Register (DBGIER on C 28 x) is used to designate time-critical interrupts – Interrupts which are enabled by both IER and DBGIER will be serviced when halted in real-time mode, regardless of global interrupt mask bit (INTM on C 28 x) CCS APPS
Viewing Real-time accesses with CCS • To enable/view real-time access to memory and registers, click on Continuous Refresh in Memory Browser and Registers view in CCS • Continuous Refresh will periodically refresh the debug views – Default refresh interval is 500 ms – Default refresh interval is configurable • CCS APPS
Using Real-time mode with CCS • To enable real-time mode, click on Enable Silicon Real-time Mode icon • Or from CCS menu Run->Debug Configurations->Target tab • When enabled: CCS APPS – The debugger will respect the DBGM bit and will not stall the processor to make the memory accesses – Time-critical interrupts can continue to be serviced while target is halted – If enabled prior to launching the debugger, will allow connecting to running device
Using Real-time mode with CCS • When real-time mode is enabled, it defaults to Polite real-time mode • In Polite mode, debugger will prevent the target from being halted while application is servicing a time-critical interrupt • If a debugger access requires target to be halted when servicing a timecritical interrupt, user will be asked whether Rude real-time mode should be enabled • In Rude mode, halt requests are serviced immediately, regardless of whether the processor is executing a time-critical ISR CCS APPS
LABS
LAB Requirements • Software: – Code Composer Studio v 6. 1. 0. 00104 Download from http: //processors. wiki. ti. com/index. php/Download_CCS and install to c: ti – control. SUITE Download from http: //www. ti. com/tool/controlsuite and install to c: ti • Hardware – F 28027 Launch. Pad • Connected to PC using USB cable – Other F 28 x hardware such as experimenter kits or Launchpads could also be used as long as the appropriate example project for that device exists in control. SUITE CCS APPS
LAB Conventions Before starting, it is important to review some lab conventions that will ease your work… • Lab steps are in black and numbered for easier reference 1. … 2. … • Explanations, notes, warnings are written in blue – Warnings are shown with – Information is marked with – Tips and answers are marked with – Questions are marked with CCS APPS
LAB 1: REAL-TIME ACCESS AND REAL-TIME MODE 30 MINUTES Open CCS and select a workspace (the default is fine) You can close the TI Resource Explorer View (it will not be used) CCS APPS
LAB 1: Real-time access and real-time mode on F 28 x • Objectives – Demonstrate how to access/modify memory and registers in real time when processor is running – Enable real-time mode in Code Composer Studio – Set up interrupts in code so they can continue to run when debugger is halted – Step through code while time critical interrupts continue to be serviced • Tools and Concepts Covered – Real-time access to memory and registers – Real-time mode and real-time interrupts CCS APPS
Importing Example Projects 1. Go to menu Project Import Existing CCS Eclipse Project 2. Click the Browse button and go to – C: ticontrol. SUITEdevelopment_kitsC 2000_Launch. Padf 2802 x_examples epwm_real-time_interrupts 3. Select the project “Example_F 2802 x. EPwm. Real. Time. Int” – Ensure the “Copy projects into workspace” is selected 4. Click Finish CCS APPS
Reviewing code 1. In Project Explorer view, expand the project Example_F 2802 x. EPwm. Real. Time. Int 2. Open the source file Example_2802 x. EPwm. Real. Time. Int. c • Observe the following: – The program configures e. PWM 1 timer and increments a counter each time interrupt is taken – LED 2 is toggled in the main routine and LED 3 is toggled in the interrupt service routine epwm 1_timer_isr – FREE_SOFT bits in EPwm 1 Regs and DBGIER. INT 3 bit are initially cleared. These bits must be set to designate e. PWM 1 interrupt as time critical and operational in real time mode after halt command. During the lab, these bits will be set through the Expressions view in CCS when processor is halted to see how real-time interrupts work CCS APPS
Important Variables • While running the labs, the following variables are of interest. Observe how they change while the program is running and halted: – EPwm 1 Timer. Int. Count - counts the number of times the ISR for PWM 1 is serviced – e. PWM 1. TBCTR - register containing the counter for PWM 1 – observe that it will stop with an emulation halt unless FREE_SOFT bits are set – e. PWM 1. TBCTL – Bits 14 and 15 (FREE_SOFT bits) establish how the counter for the PWM reacts to an emulation halt command. The default 00 in these bits will stop the counter when a halt command is received. A 10 or 11 will allow the counter to run freely after the halt command is received – DBGIER. INT 3 - Debug Interrupt Enable Register bit that is used to designate whether the corresponding interrupt is time critical. Setting this bit will designate the PWM interrupt to be time critical and operate as realtime interrupt CCS APPS
Build the Example Project 1. Go to the Project Explorer view 2. Right-click on Example_F 2802 x. EPwm. Real. Time. Int and select “Build Project” CCS APPS
Create a Target Configuration File 1. Right-click on the project and go to File New Target Configuration File 2. Specify f 28027 lp as the name and click Finish 3. In the “Connection” field, select Texas Instruments XDS 100 v 2 USB Debug Probe 4. In the “Board or Device” filter field, type F 28027 5. Select TMS 320 F 28027 6. Click Save CCS APPS
Launch the Debugger 1. Click on the debug button (green bug icon) to debug the project This will build the project (if required), launch the debugger, flash the program onto the device and run to main() 2. Add these variables to the Expressions view: – – EPwm 1 Timer. Int. Count e. PWM 1. TBCTR e. PWM 1. TBCTL DBGIER. INT 3 CCS APPS
Setup Continuous Refresh 1. Open the Memory Browser and enter &EPwm 1 Timer. Int. Count in the address field to view the address of that variable 2. Arrange the views such that the Expressions, Memory Browser and Registers views are all visible at once 3. In Registers view, expand the e. PWM 1 register 4. Enable Continuous Refresh on all three views CCS APPS
Run the program 1. Click Resume to run the program – The LEDs on the board should be blinking, LED 2 (toggled in main routine) and LED 3 (toggled in ISR routine). LED 2 appears to stay on continuously but is actually just blinking at a very high speed. The Expressions, Memory Browser and Registers view update in real-time while the processor is running – The LEDs on the board should stop blinking and the views stop updating CCS APPS 2. Halt the core by clicking the Suspend button
Enable Real-time Mode 1. Enable real-time mode in CCS by clicking the button shown here: 2. Click Resume to run the core 3. In the Expressions view, set e. PWM 1. TBCTL to 0 x 8090 to set FREE_SOFT bit to 2, which will enable free run mode on the counter – Setting this bit allows the timer to continue to increment even when the core is halted 4. Click the Suspend button to halt the core – Notice that e. PWM 1. TBCTR keeps changing in the Expressions view even when the target is halted as it is set to free run • CCS APPS However note that the interrupt is not being serviced (EPwm 1 Timer. Int. Count is not incrementing and LED 3 has stopped blinking) as it has not been designated as a real-time interrupt
Real-time Interrupts 1. In the Expressions view, set DBGIER. INT 3 to be 1 to designate PWM 1 as a real-time interrupt – Notice that EPwm 1 Timer. Int. Count now continues to increment even though target is halted. Similarly notice that LED 3 which is toggled within ISR has resumed toggling while LED 2 which is toggled within main routine remains stopped 2. Click the Step Into button code several times to single-step through the – Notice that LED 2 toggles on and off as you step through the main routine while LED 3 continues to blink • These steps demonstrate that, in real-time mode, the PWM 1 interrupt that we designated as time critical is continuing to be serviced even when the core is halted in the Debug View to close the debug CCS APPS 3. Click the Terminate button session
LAB 2: CONNECT TO RUNNING PROGRAM 15 MINUTES Open CCS and select a workspace (the default is fine) You can close the TI Resource Explorer View (it will not be used) CCS APPS
LAB 2: Connect to running program • Objectives – Connect to a program already flashed and running on target without resetting the device • Tools and Concepts Covered – Debug properties and Real-time mode CCS APPS
Change build configuration of Project 1. In Project Explorer view, right-click on Example_F 2802 x. EPwm. Real. Time. Int, go to Build Configurations>Set Active and select Flash – This will change the build configuration to the Flash version CCS APPS
Launch the Debugger (default settings) 1. Click on the Debug button (green bug icon) to debug the project This will build the project (if required), launch the debugger, flash the program onto the device and run to main() 2. Click Resume in the Debug view to run the program – Verify that LED 2 and LED 3 are blinking as expected. Note that LED 2 may look like it is continuously on but is actually just blinking at a very high speed. 3. Click the Terminate button session in the Debug View to close the debug CCS APPS 4. Unplug and re-plug the USB cable to power cycle the board so the program starts running from Flash
Modify the Debug settings 1. Go to menu Run->Debug Configurations and select Example_F 2802 x. EPwn. Real. Time. Int in the left pane 2. Go to Program tab and select Load Symbols Only This will load just the symbols for the program rather than reflashing the whole program every time the debugger is launched 3. Go to Target tab->Auto Run and Launch Options and check the box for Enable realtime mode 4. Click Apply and Close CCS APPS
Launch the Debugger 1. Click on the Debug button (green bug icon) to debug the project This will build the project (if required), launch the debugger, connect to the device, load symbols in this case, and halt the target at the current point of execution 2. Click Resume from that point in the Debug view to continue running the program – Verify that LED 2 and LED 3 are blinking as expected in the Debug View to close the debug CCS APPS 3. Click the Terminate button session
Modify the Debug settings 1. Go to menu Run->Debug Configurations and select Example_F 2802 x. EPwn. Real. Time. Int in the left pane 2. Go to Target tab->Program/Memory Load Options and uncheck the box for Halt the target on a connect CCS APPS 3. Click Apply and Close
Launch the Debugger 1. Click on the Debug button (green bug icon) to debug the project This will build the project (if required), launch the debugger, connect to the device, load symbols in this case, and leave the target running Observe the LEDs blinking and variables changing in the Expressions view (if Continuous Refresh icon is enabled) to confirm program is running 2. Click the Suspend button in the Debug view to halt the core and perform other debugging actions, as required in the Debug view to close the debug CCS APPS 3. Click the Terminate button session
Summary • After completing these labs you should now be familiar with: – Accessing memory and registers in real time while the processor is running – Enabling real-time mode in Code Composer Studio – Setting up interrupts so they can continue to run when the debugger has halted the processor – Stepping through code while time critical interrupts continue to be serviced – Using real-time mode to connect to a program already flashed and running on target CCS APPS
- Slides: 32