how can I active breakpoints after reset ?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

how can I active breakpoints after reset ?

1,907 次查看
electro
Contributor I
Hello,
I am using Metrowerks Code Warrior Debugger for an application based on the MC9S12DG128.
The application is controlled by two buttons:
   - button 1 puts it in stand-by (execution of the instruction STOP)
   - button2 wakes up the application (it sends an XIRQ to the MC9S12); when waked up, the application makes first a reset (via the watchdog) so as to initialise everything in the microcontroller.
 
Now I want to debug the early stages of the execution, just after the reset generated by the watchdog.
While the application is running, I set a breakpoint with the debugger in the code executed after reset. Then I press button1 (stand-by), then button2 (wake-up). The program doesn't stop at the breakpoint: it seems that it must be launched by the debugger (command Start) for the breakpoints to be active. If I stop the program (command Halt) and then re-run it (Start), breakpoints are active again,.... but the portion of program I wanted to debug has been excuted a long time ago.
I tried different things (instruction BGND in the code to debug, set the breakpoint wihile application running or in stand-by, write directly the address of the breakpoint in breakpoint registers) but nothing worked. I understand that reset clears the breakpoints, and the only way to rewrite them is to launch the application via the command Start of the debugger. Have you some idea of the way to "automatically" set a breakpoint when my program gets out of reset ?
Thanks.
 
标签 (1)
标记 (1)
0 项奖励
回复
2 回复数

753 次查看
kef
Specialist I
Reset does 1) reset breakpoint hardware and 2) escape from special single chip with BDM enabled to normal single chip with BDM disabled. So you lose both, hardware breakpoints and the ability to stop on BGND and pass control to BDM firmware. BGND is just a multicycle NOP in your case. Breakpoints also can't pass control to BDM firmware while BDM is inactive. You can't activate BDM from firmware.
 

753 次查看
electro
Contributor I
Hello Kef,
 
     Thank you for your answer. I had missed the fact that the HC12 went out of reset in normal mode with BDM disabled, which explains why the BGND instruction didn't work.
 
   With this in mind, I found the following workaround for my problem : write an instruction bra * at the place I want my program to stop, instead of setting a breakpoint.
 
   Now, after the reset generated when I press button 2 (i.e. wake up), the execution loops on the instruction bra *, and I can send the command Stop with the debugger. Then I set program counter to next instruction and begin stepping through my program. Sort of "poor man breakpoint".
 
    Naturally, this is not ideal, as I have to modify my program before debugging, but at least I can debug ! Perhaps there is a better solution ?
 
Regards
0 项奖励
回复