Reset on Halt or on Breakpoints
I need to continue coding on a project I worked on a while back.
Jumping in and fixing stuff I have managed to get into some kind of
mess. The cpu seems to always reset to the beginning of the program
when I halt it. I kind of figured this may be do to using the WDT &
SLEEP combination, not sure, and that I have something wrong there,
but that is only the start of the problem. When ever I add a
breakpoint, the program resets to the start. THIS, makes debug of
the program impossible of course. So after much hacking, I tried to
back way up to the basic LED blink approach. Using a 'movwf TRISC'
to set the port and a toggle of the port bit, LED works OK and
functions with breakpoints. Next I try to add my 'call Init_Ports'
routine back in and with F9 the program runs one time and resets to
the start. If I put in a breakpoint before the 'call', it stops OK
on the bkpt. If I put in a bkpt after the 'call', it runs ignoring
the bkpt and resets to the start(LED blinks once - code is below).
If I single step, every time I get it to the 'movwf TRISA' statement
with a green arrow, the arrow changes to a flat blue pointer on the
next F7 step, and then resets the green arrow back to the beginning
of the program on the next F7 step. What is going on with this?
What is the blue pointer on the statement line suppose to tell me?
I have looked at the Disassembly Code and the statements and hex seem
OK. Why would it always reset on this 'TRISA' statement? I have
moved it around with some 'nop' lines and it waits till this line and
sends the program counter back to the beginning when I am single
stepping. It will pass through a 'TRISC' statement OK, just not
a 'A' statement.
The code -
call Init_Timer1 ; Does this call OK
nop ; Bkpt here works OK
nop ; Bkpt here is ignored - program continues - LED
blinks - program resets to Start
bcf PORTC, 2 ; LED ON (sinks)
bsf PORTC, 2 ; LED OFF
; Skipping the lines where I 'clrf' on all ports
movwf TRISC ; Will execute OK
movwf TRISA ; Line that green arrow changes to blue ptr
I don't know if this is causing my full program to reset each time I
try to halt it or put a bkpt in it, but something is wrong here.
Would anyone guess that they are related or do I have another problem
Thanks for the help, I don't know what to do to get past this,