background image

dsPIC33 Debugger     |    17

©

1989-2022

   Lauterbach        

 

                   

                            

Programming the On-chip FLASH of the dsPIC33

The PRACTICE script for programming of the on-chip FLASH of a dsPIC33 can be found in the TRACE32 
demo folder 

~~

/demo/pic/flash/.

For programming the program memory of a dsPIC33E core, the script dspic33epxxx.cmm should be used. 
For programming the program memory of a dsPIC33C master core with a single partition, the script 
dspic33cxxxx.cmm should be used. For dual partition configurations of a dsPIC33C core, the script 
dspic33cxxxx_dual.cmm is suitable. The dspic33chxxxslave.cmm is intended for flashing a dsPIC33CH 
slave core.

Please be aware that these are just example scripts. They might need some adaption to fit your MCU.

To debug only the slave core of a dsPIC33CH target, the FLASH of the master core must be programmed at 
least with a stub function including the hardware configuration words for the master and slave core. 
Afterwards the slave core can be programmed. For further details see the scripts mentioned above.

Additionally, an application can be flashed to the chip’s program memory where the debug ports of the target 
are disabled. To do so, the target must be brought to Prepare mode before the binary is written to flash 
memory. In this case, the scripts mentioned above will fail. 

Special Hints, Restrictions, and Known Problems

Special Hints

Due to the architecture of the dsPIC33 microcontrollers, the target will always halt two assembler 
instructions after an on-chip breakpoint’s address. This can lead to imprecisions when doing HLL 
steps.

Restrictions

The use of SW breakpoints is discouraged as setting them leads to faster reduction of the 
target’s number of flash erase cycles.

Go.Return

 will stop the target right after the current function is left. Because of the on-chip 

breakpoint implementation, the debugger can not stop the target at the function epilog.

Known Problems

Stack frames not correctly shown when entering library functions.

NOTE:

All problems will be fixed in one of the next SW versions without notice! 

Summary of Contents for dsPIC33

Page 1: ...MANUAL Release 02 2022 dsPIC33 Debugger ...

Page 2: ... Quick Start 9 Start a New Debug Session 9 Programming a Productive Application Binary 10 Troubleshooting 12 FAQ 13 dsPIC33 Specific Implementations 14 dsPIC33 Debug Monitor 14 Breakpoints 14 Software Breakpoints 14 On chip Breakpoints for Instructions 15 On chip Breakpoints for Data 15 Memory Classes 16 Programming the On chip FLASH of the dsPIC33 17 Special Hints Restrictions and Known Problems ...

Page 3: ...reak on watchdog time out 23 SYStem Option CLockSWitch Enable clock group switch 23 SYStem Option ENableWDT Enable watchdog timer 23 SYStem Option FastRC Use FRC as debug port clock 24 SYStem Option FreezePer Freeze peripherals on break or breakpoint 24 SYStem Option IMASKASM Disable interrupts while single stepping 24 SYStem Option IMASKHLL Disable interrupts while HLL single stepping 25 SYStem O...

Page 4: ...r 2022 History 01 Jan 21 Added support for dsPIC33E family 04 May 20 Supplemented section Start a New Debug Session with description of implemented feature SYStem DETECT CPU 20 Feb 20 New command SYStem Mode Prepare New section Programming a Productive Application Binary ...

Page 5: ...the target while the target power is off 2 Connect the host system the TRACE32 hardware and the debug cable 3 Power ON the TRACE32 hardware 4 Start the TRACE32 software to load the debugger firmware 5 Connect the debug cable to the target 6 Switch the target power ON 7 Configure your debugger e g via a start up script Power down 1 Switch off the target power 2 Disconnect the debug cable from the t...

Page 6: ... independent information Training Debugger Basics training_debugger pdf Get familiar with the basic features of a TRACE32 debugger T32Start app_t32start pdf T32Start assists you in starting TRACE32 PowerView instances for different configurations of the debugger T32Start is only available for Windows General Commands general_ref_ x pdf Alphabetic list of debug commands Architecture specific inform...

Page 7: ...u can now search the demo folder and its subdirectories for PRACTICE start up scripts cmm and other demo software You can also inspect the demo folder manually in the system directory of TRACE32 The demo pic folder contains flash Scripts for target based programming and example declarations for internal flash hardware Ready to run debugging and flash programming demos for evaluation boards Recomme...

Page 8: ... Overview Example configuration for a single core debugger Please consider the tips given in the chapter Connector Type and Pinout page 26 POWER DEBUG USB INTERFACE USB 3 POWER DEBUG INTERFACE USB 3 PC or Workstation USB Cable Target Debug Connector Debug Cable ...

Page 9: ...detect the connected target 3 Reset the target and enter debug mode This command resets the CPU on the target enables On Chip Debug Mode and halts at address 0x0 The CPU stops executing any instruction and the user is able to download and test the code After this command is executed it is possible to access memory and registers If this command results in an error the target might not be prepared f...

Page 10: ...TRACE32 software WinCLEAR Clear all windows SYStem Up Reset the target and enter debug mode DO demo pic flash script cm m Load the target application with the family specific script Set the stack pointer to address 8000 PER view Show clearly arranged peripherals in window List Mix Open source code window Register view SpotLight Open register window Frame view Locals Caller Open the stack frame wit...

Page 11: ...This command resets the CPU on the target and enables program memory access 4 Write the configuration information first The address range given in the Data LOAD auto command must be modified to point to the last flash page of the target which includes the configuration memory space 5 Write the remaining program memory The program binary selected for the Data LOAD auto command should be the same as...

Page 12: ...access size size bytes No special event Internal error please consult your Lauterbach representative Memory address address is not aligned to access size size No special event Internal error please consult your Lauterbach representative Invalid memory access size size bytes address address No special event Internal error please consult your Lauterbach representative Memory access timeout Reading f...

Page 13: ...e Maybe there is the need to set jumpers on the target to connect the correct signals to the debug connector The debugger will not work for example if PGEC signal is directly connected to ground on target side The target is in an unrecoverable state Re power your target and try again The default debug clock prescaler is too low In this case try SYStem CLockPrescaler 0xA0 and optimize the speed whe...

Page 14: ... the flash memory and does not affect the space available for user programs In general the debug monitor code must be present in the target memory before the debugger can be used To load the suitable Lauterbach debug monitor into the target s flash memory the command FLASH UNSECUREerase should be used This command erases the user code memory and configures the currently used debug port too Breakpo...

Page 15: ...type i e read write or both or the data value Up to five on chip breakpoints of dsPIC33 MCUs can be used as data breakpoints On the slave core of a dsPIC33CH derivative one data breakpoint is available In case of an on chip data breakpoint every load and store instruction is checked with respect to the breakpoint address access type and the value The data breakpoints are especially useful to find ...

Page 16: ...different memory access classes are available To access a memory class write the class in front of the address For example use D to access the data memory Thefollowingexamplesreturndifferentresults sincethedsPICarchitectureusestheHarvardArchitecture Access Class Description D Data P Program Data dump D 0x00 Data dump D 0x100 Data dump P 0x100 ...

Page 17: ...re Afterwards the slave core can be programmed For further details see the scripts mentioned above Additionally an application can be flashed to the chip s program memory where the debug ports of the target are disabled To do so the target must be brought to Prepare mode before the binary is written to flash memory In this case the scripts mentioned above will fail Special Hints Restrictions and K...

Page 18: ...the chip on the target board and how to access the on chip debug and trace facilities in order to accomplish the debugger s operations Alternatively you can modify the target configuration settings via the TRACE32 command line with the SYStem CONFIG commands Note that the command line provides additional SYStem CONFIG commands for settings that are not included in the SYStem CONFIG state window Fo...

Page 19: ...ort DEBUGPORT DebugCable0 DebugCableA DebugCableB DEBUGPORTTYPE SPI Slave ON OFF TriState ON OFF DEBUGPORT DebugCable0 DebugCa bleA DebugCableB It specifies which probe cable shall be used e g DebugCableA or DebugCableB At the moment only the CombiProbe allows to connect more than one probe cable Default depends on detection DEBUGPORTTYPE SPI It specifies the used debug port type SPI At the moment...

Page 20: ...ate the debug port Default OFF If the system is locked no access to the debug port will be performed by the debugger While locked the connector of the debugger is tristated The intention of the SYStem LOCK command is for example to give debug access to another tool The process can also be automated see SYStem CONFIG TriState Format SYStem CPU cpu cpu DSPIC33CH512MP508 DSPIC33CK32MP102 Format SYSte...

Page 21: ...t should be performed A white S against a red background in the TRACE32 state line warns you that the program is no longer running in real time To update specific windows that display memory or variables while the program is running select the memory class E or the format option E Format SYStem MemAccess mode mode Denied StopAndGo Denied No memory access is possible while the CPU is executing the ...

Page 22: ...istated Prepare Resets the target The debugger initializes the debug port but does not connect to the CPU This debug mode is used if the CPU shall not be debugged but programmed with an application binary intended for productive use Go Resets the target initializes the debug port and starts program execution Attach Initializes the debug interface and connects to core while program remains running ...

Page 23: ...ng mode and this option is disabled a Watchdog time out resets the CPU SYStem Option CLockSWitch Enable clock group switch Default ON If enabled a loaded program can switch the clock group used by the CPU Otherwise a break occurs SYStem Option ENableWDT Enable watchdog timer Default ON This option enables a global Watchdog timer The system s reaction to a Watchdog time out can be configured by usi...

Page 24: ... enabled the peripherals freeze when the program execution is interrupted If disabled the peripherals run normally when a breakpoint or break command occurs SYStem Option IMASKASM Disable interrupts while single stepping Default ON If enabled the interrupt enable flag of the EFLAGS register will be cleared during assembler single step operations After the single step the interrupt enable flag is r...

Page 25: ... please refer to the target chip s data sheet SYStem Option PoWeRSaVe Enable PWRSAV instruction ON Default ON Format SYStem Option IMASKHLL ON OFF Format SYStem Option PARTitionconfig SinglePARTition DUALpartition PROTectedDualpart PRIVilegedDualpart SinglePARTition The Flash memory will be used as one partition DUALpartition The Flash memory will be split in two partitions Both partitions have th...

Page 26: ...struction will cause the chip to enter Idle or Sleep mode Otherwise the program execution will be interrupted SYStem state Display SYStem state window Displays the SYStem state window for system settings that configure debugger and target behavior Format SYStem state ...

Page 27: ...dsPIC33 Debugger 27 1989 2022 Lauterbach CPU specific TrOnchip Commands The TrOnchip command group is not available for the dsPIC33 debugger ...

Page 28: ... target Do not connect the N C pins Even if pins 7 and 8 are present on the provided adapter LA 2773 If there are dsPIC33 derivatives which can be debugged via JTAG the future use pinout will be used VTREF is the processor power supply voltage It is used to detect if target power is on and it is used to supply the output buffers of the debugger That means the output voltage of the debugger signals...

Reviews: