AnsweredAssumed Answered

Single stepping vs running?

Question asked by ThorMJ on Jul 1, 2013
Latest reply on Jul 1, 2013 by ThorMJ

In my large project, if I single-step-over (F10 -- each F10 corresponds to the number below) the system through startup, it runs fine.

However, if I "Run" from the start (or I use power-on-reset), it fails to start properly...

What would be a good way to debug this?



0. Main() entered

1. Set clock speed and hardware

2. Determine cause of reset -- if watchdog, hang here [breakpointed]

3. Set values of a large data structure (defaults or load from flash)

4. Initialize serial port with baud rate in data structure

5. Print sign-on message

6. Initialize modbus library

  6a. Re-init serial port

  6b. Do a bunch of CRC table stuff

7. Start Timer0 state machine

8. Begin Forever Loop

  8a. Blink LED

  8b. Handle modbus serial stuff (serial ISR puts data into a buffer; this causes the modbus to act on the buffer if I have a packet).

  8c. Wait for state machine to advance and go back to 8a.


Stepping through it, it all works in order and I can tell it to run at step 8 (and modbus works and everything!).

Running from step 0, it doesn't start up.  When you stop the CPU, it's stuck in the serial ISR, and the ISR returns to step 6a, no matter how much time you allow to elapse (it should take ~3 seconds to start)... and it seems to be stuck in a serial ISR loop (it keeps entering the serial ISR, even though COMSTA0=0x60 and COMIEN0 = 0x00 [should be 0x01!]).


It seems to do better if I comment out 6a, but I'm worried that that's just masking the problem.  Is there an amount of time that has to elapse (or are you not allowed to mess with the COM registers when the ISR is enabled/on)?