views:

218

answers:

1

I'm just getting started learning FreeScale DSCs (MC56F800x series). I've done some work with AVRs using both AVR Studio on Windows and Eclipse and avr-gcc on Linux. CodeWarrior is just not as intuitive.

Right now I'm stuck trying to debug a simple program. I start the debugger using the built-in simulator, but it never reaches the first line of main(). Instead it seems to get stuck in some initialization code (MC56F8006_init.asm), specifically this line:

    ;; Loop until OCCS_STAT[LCK0] = 1
wait_for_lock: 
    brclr   #OCCS_STAT_LCK0,x:>OCCS_STAT,wait_for_lock

I've let it run for quite a while and it never gets past this. It's obviously waiting for something, but what? You would think the simulator would just work... argh. Maybe there's some options I can change to make it pass this step?

I'm going to keep digging and will post an answer here if I find it first.

Updates:

Here's what I've found:

OCCS

  • On Chip Clock Synthesis

brclr

  • Branch if Bits Clear

The instruction loops until OCCS_STAT LCK0 is set. This register means the on-chip oscillator's PLL has locked (waits for clock stabilization).

I'm still not sure why the simulator spins forever on this line, and how I can solve this without resorting to hacking up the init code (which is part of the code library and not within my project).

+2  A: 

I am not familiar with the part or the simulator, but it seems likely that the simulator is instruction-set-only and does not simulate the PLL hardware.

In most embedded development systems, the run-time startup code is provided as source and you could modify it (or rather make a local copy in your project and assemble and link that to override the default start-up). Alternately you could simply place a breakpoint in this loop, and advance the program-counter register to get it out of the loop. In many debuggers it is possible to attach a script to a breakpoint to do this automatically.

Clifford
Thanks for the suggestion on breakpoints. I found the easiest solution was to use a "SkipPoint" which is one of the "EventPoint" options. It seems to just simply skip the line it's placed on. Exactly what I needed!
Mark Renouf