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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/16/03 19:23
Read: times


 
#39167 - please check this simple code
writing a program which generates a 1Khz square wave using ony 8 bit Auto Reload timer 0 , out on P1.0

1 Khz = 1000 Hz = 0.0001 seconds = 1000 Micro-Seconds.

since the maximum value that can come in 8 bit auto-reload mode is 255 so taking the value 250
255-250= 05 so the timer should start from 05 to count 250.

Program is as follows:-

ORG 00H
MOV Ro,#02D
( as i am using DJNZ command to make the timer add 250+250 to produce 500 micro-seconds as in case of square wave of 1000 micro-seconds , for half time 500 micro-seconds high single should go then for next 500 low single should go)
MOV TMOD,#10B ( setting timer in 8 bit auto-reload mode)
LOOP: MOV TH0,#05D
SETB TR0
DJNZ Ro,LOOP ( this will make the timer to produce 500 micro-seconds, i have doubt on this one)
JNB TF0,$
CLR TF0
CPL P1.0 ( where we need the output)
RET

Or there is some problem with the timer over flowing condition that i used that is before CLR TF0 i have used DJNZ will it add 250+250 or do something else?

List of 3 messages in thread
TopicAuthorDate
please check this simple code            01/01/70 00:00      
   RE: please check this simple code            01/01/70 00:00      
      I have no idea about intreputts            01/01/70 00:00      

Back to Subject List