Understanding Real-time Debug Techniques for Embedded Development

Slide Note
Embed
Share

Real-time debugging in embedded systems involves different modes like stop mode and real-time mode, each offering unique capabilities for accessing memory, registers, and handling interrupts. This technique allows developers to examine and modify memory contents while the processor is running, enabling efficient debugging without the need for complete halting. The real-time mode can be further categorized into polite and rude modes, affecting how memory accesses and halts are handled by the debugger. This article explores the nuances of real-time debugging and its applications in embedded development.


Uploaded on Sep 21, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Real-time Debug Embedded Development Tools

  2. 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 Real-time debug capabilities vary by device and are supported via different methods CCS APPS

  3. Real-time Debug capabilities Access to memory while the processor is running Supported on Tiva, Stellaris, Hercules, C28x, C66x, C64x, C55x 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/28x 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 C28x, C66x, C64x, C55x Enabled through hardware (ICEMaker) Service interrupts while the processor is halted Supported on C28x, C66x, C64x, C55x Enabled through hardware (ICEMaker) CCS APPS

  4. 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 DBGM settings are ignored by debugger and accesses are made anyway Allows for error recovery if application sets these bits and then hangs CCS APPS

  5. 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 C28x) 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 C28x) CCS APPS

  6. 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

  7. 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: 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 CCS APPS

  8. 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 time- critical 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

  9. LABS

  10. LAB Requirements Software: Code Composer Studio v6.1.0.00104 Download from http://processors.wiki.ti.com/index.php/Download_CCS and install to c:\ti controlSUITE Download from http://www.ti.com/tool/controlsuite and install to c:\ti Hardware F28027 LaunchPad Connected to PC using USB cable Other F28x hardware such as experimenter kits or Launchpads could also be used as long as the appropriate example project for that device exists in controlSUITE CCS APPS

  11. 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

  12. 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

  13. LAB 1: Real-time access and real-time mode on F28x 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

  14. Importing Example Projects 1. Go to menu Project Import Existing CCS Eclipse Project 2. Click the Browse button and go to C:\ti\controlSUITE\development_kits\C2000_LaunchPad\f2802x_examples \epwm_real-time_interrupts 3. Select the project Example_F2802xEPwmRealTimeInt Ensure the Copy projects into workspace is selected 4. Click Finish CCS APPS

  15. Reviewing code 1. In Project Explorer view, expand the project Example_F2802xEPwmRealTimeInt 2. Open the source file Example_2802xEPwmRealTimeInt.c Observe the following: The program configures ePWM1 timer and increments a counter each time interrupt is taken LED2 is toggled in the main routine and LED3 is toggled in the interrupt service routine epwm1_timer_isr FREE_SOFT bits in EPwm1Regs and DBGIER.INT3 bit are initially cleared. These bits must be set to designate ePWM1 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

  16. Important Variables While running the labs, the following variables are of interest. Observe how they change while the program is running and halted: EPwm1TimerIntCount - counts the number of times the ISR for PWM1 is serviced ePWM1.TBCTR - register containing the counter for PWM1 observe that it will stop with an emulation halt unless FREE_SOFT bits are set ePWM1.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.INT3 - 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 real- time interrupt CCS APPS

  17. Build the Example Project 1. Go to the Project Explorer view 2. Right-click on Example_F2802xEPwmRealTimeIntand select Build Project CCS APPS

  18. Create a Target Configuration File 1. Right-click on the project and go to File New Target Configuration File 2. Specify f28027lp as the name and click Finish 3. In the Connection field, select Texas Instruments XDS100v2 USB Debug Probe 4. In the Board or Device filter field, type F28027 5. Select TMS320F28027 6. Click Save CCS APPS

  19. 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: EPwm1TimerIntCount ePWM1.TBCTR ePWM1.TBCTL DBGIER.INT3 CCS APPS

  20. Setup Continuous Refresh 1. Open the Memory Browser and enter &EPwm1TimerIntCount 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 ePWM1 register 4. Enable Continuous Refresh on all three views CCS APPS

  21. Run the program 1. Click Resume to run the program The LEDs on the board should be blinking, LED2 (toggled in main routine) and LED3 (toggled in ISR routine). LED2 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 2. Halt the core by clicking the Suspend button The LEDs on the board should stop blinking and the views stop updating CCS APPS

  22. 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 ePWM1.TBCTL to 0x8090 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 ePWM1.TBCTR keeps changing in the Expressions view even when the target is halted as it is set to free run However note that the interrupt is not being serviced (EPwm1TimerIntCount is not incrementing and LED3 has stopped blinking) as it has not been designated as a real-time interrupt CCS APPS

  23. Real-time Interrupts 1. In the Expressions view, set DBGIER.INT3 to be 1 to designate PWM1 as a real-time interrupt Notice that EPwm1TimerIntCount now continues to increment even though target is halted. Similarly notice that LED3 which is toggled within ISR has resumed toggling while LED2 which is toggled within main routine remains stopped 2. Click the Step Into button several times to single-step through the code Notice that LED2 toggles on and off as you step through the main routine while LED3 continues to blink These steps demonstrate that, in real-time mode, the PWM1 interrupt that we designated as time critical is continuing to be serviced even when the core is halted 3. Click the Terminate button in the Debug View to close the debug session CCS APPS

  24. 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

  25. 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

  26. Change build configuration of Project 1. In Project Explorer view, right-click on Example_F2802xEPwmRealTimeInt, go to Build Configurations- >Set Active and select Flash This will change the build configuration to the Flash version CCS APPS

  27. 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 viewto run the program Verify that LED2 and LED3 are blinking as expected. Note that LED2 may look like it is continuously on but is actually just blinking at a very high speed. 3. Click the Terminate button in the Debug View to close the debug session 4. Unplug and re-plug the USB cable to power cycle the board so the program starts running from Flash CCS APPS

  28. Modify the Debug settings 1. Go to menu Run->Debug Configurations and select Example_F2802xEPwnRealTimeInt 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

  29. 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 in the Debug viewto continue running the program from that point Verify that LED2 and LED3 are blinking as expected 3. Click the Terminate button in the Debug View to close the debug session CCS APPS

  30. Modify the Debug settings 1. Go to menu Run->Debug Configurations and select Example_F2802xEPwnRealTimeInt in the left pane 2. Go to Target tab->Program/Memory Load Options and uncheck the box for Halt the target on a connect 3. Click Apply and Close CCS APPS

  31. 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 3. Click the Terminate button in the Debug view to close the debug session CCS APPS

  32. 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

Related


More Related Content