Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/03/01 08:13
Read: times


 
#13793 - Timer 0 and blinking a LED
I know this is a common problem, but I need to blink a LED using timer0. I'm using a 89C1051 and as far as I can tell, this chip has that timer. I wrote some code, it failed... So I looked in the FAQ, found some code, but it uses interupts, but I don't like those things. As far as I can tell I set the timer up correctly, and started it too. Timer0 should be in mode1, using the full count of 65535, which will give me ~5.4 over flows per second.
This is what I came up with for a 5 second blink transition.

ORG 0000
START:
MOV R0,#0
MOV TL0,#0
MOV TH0,#0
ORL TMOD,#00000001B
SETB TR0
CLR 20
CLR P1.7
MAIN:
JNB TF0,$
CLR TF0
INC R0
CJNE R0,#26,MAIN
NEQUL:
MOV R0,#0
CPL 20
MOV C,20
MOV P1.7,C
SJMP MAIN

I ran it in JSIM, but it won't give the status of pin P1.7, but the timer did count.

Am I just losing my coding skills?
Thanks,
Ben

List of 5 messages in thread
TopicAuthorDate
Timer 0 and blinking a LED            01/01/70 00:00      
RE: Timer 0 and blinking a LED            01/01/70 00:00      
RE: Timer 0 and blinking a LED            01/01/70 00:00      
RE: Timer 0 and blinking a LED            01/01/70 00:00      
RE: Timer 0 and blinking a LED            01/01/70 00:00      

Back to Subject List