Hello everyone,
I am trying to make a simple timer for ages now. I have aPIC16877A chip im using. I have a program that is a binary counter that shows up on LED's that i have attached to the PORTB pins. The counter works fine when i use the sleep call, but as soon as i replace the sleep call with my or any online delay routine the counter only seems to run for part way and then somehow the program starts over without ever completing the code. I know this because at the end of the counter program upon termination the program will flash and then do a sleep call. The current delay routine i am using from online is here
delay ; 2 cycles for call
clrf DE1 ; 1 cycle to clear counter variable
Dloop
nop
decfsz DE1,F ; These two instructions provide a
goto Dloop ; (256 * 3) -1 cycle count
return ; 2 cycles for return
i got the code from this page, **broken link removed** i have setup as the following in my program
DE1 equ 25h
Any ideas as to why the delay above dosent work? it seems to work but then the program resets itself after only part way through the counting. Replacing the one line the program that calls the delay with sleep fixes the problem but i would like to use my own delay routine.
I am trying to make a simple timer for ages now. I have aPIC16877A chip im using. I have a program that is a binary counter that shows up on LED's that i have attached to the PORTB pins. The counter works fine when i use the sleep call, but as soon as i replace the sleep call with my or any online delay routine the counter only seems to run for part way and then somehow the program starts over without ever completing the code. I know this because at the end of the counter program upon termination the program will flash and then do a sleep call. The current delay routine i am using from online is here
delay ; 2 cycles for call
clrf DE1 ; 1 cycle to clear counter variable
Dloop
nop
decfsz DE1,F ; These two instructions provide a
goto Dloop ; (256 * 3) -1 cycle count
return ; 2 cycles for return
i got the code from this page, **broken link removed** i have setup as the following in my program
DE1 equ 25h
Any ideas as to why the delay above dosent work? it seems to work but then the program resets itself after only part way through the counting. Replacing the one line the program that calls the delay with sleep fixes the problem but i would like to use my own delay routine.
Last edited: