cancel
Showing results for 
Search instead for 
Did you mean: 

code loop problem

jneely
Associate II
Posted on June 11, 2003 at 15:24

code loop problem

2 REPLIES 2
jneely
Associate II
Posted on May 17, 2011 at 10:16

I am using the st72141k for a motor controller. In order for my stop motor routine to work correctly, I have to constantly reset the

watchdog timer in the shut down routine. Here is the code:

.stop_motor

ld A, #$00 ; set MOE bit to 0

ld MCRA, A

.stall

ld A, #$7F

ld WDGCR, A ; reset watchdog timer

ld A,#$FF ; turn light off

ld PBDR,A

call wait_500ms ; 500ms delay

ld A,#$FB ; turn light on

ld PBDR,A

jp stall ; repeat forever

Now, the code above will stop the motor, but the LED will not flash as it should. I can run the flash code (turns output pin on/off that is tied to the negative voltage side of the LED) else where in the program and the LED will flash, but when it is in this stall loop it never works. The wait_500ms is just a counter that counts for ~500ms. I even have that reset the watchdog as the watchdog timeout is ~98ms. If I do not reset the watchdog then the motor stops momentarily and then tries to restart repeadly and usually at that point a driver fails.

Any ideas? Thanks for the help.

maxime2399
Associate II
Posted on May 17, 2011 at 10:16

first you need to be servicing the watchdog in your wait_500ms routine...

then you need also to wait 500 ms before turning the LED off again otherwise the time off will be so short that you won't be able to see it...