MC9S08PA..Code for Delay routine

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC9S08PA..Code for Delay routine

398 Views
mikee_
Contributor I


Hello,

 

I am writing this piece of code in order to insert a delay in my execution cycle.

 

The code is the following:

 

DELAY:                STHX    DLY_A  ; (4)

LOOPOUT:          STX     DLY_B  ; (3)

LOOPIN:    

                             DEC     DLY_B  ; (4)

                             BNE     LOOPIN ; (3)

                             DEC     DLY_A  ; (4)

                             BNE     LOOPOUT ;(3)

                             RTS

 

I am using code warrior 10.6

 

After starting the debug process. The communication with the micro-controller will stop after debugger will step in and is able to do few iterations .

 

PS: watchdog is deactivated.

 

Looks really weird.

 

Any help?

 

Any body has a better way to insert delay?

 

Many thanks

Labels (1)
0 Kudos
1 Reply

230 Views
tonyp
Senior Contributor II

Hard to tell what's wrong without more complete code.  For example, where are DLY_A and DLY_B variables located?

BTW, here's a sample delay routine to give you an idea (but for ASM8 assembler)

0 Kudos