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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/28/04 16:19
Read: times


 
#69405 - RE: 8051 12 hour clock
Responding to: ???'s previous message
ok this is the main program and im working on the interrupt might be a few bugs someone please check out
org 8100h
hour set R0
minute set R1
second set R2
ov_cnt set R3
org 2bh ;Timer 2 interrupt vector
dec ov_cnt
clr TF2
reti
org 100h ;starting address of the program
clr TF2 ;clear the TF2 flag
mov T2MOD,#00 ;select timer mode
mov T2CON,#04h ;initialize T2CON register
mov TH2,#3ch ;initialize Timer 2 registers to 3CAFH
mov TL2,#afh ;"
mov RCAP2H,#3CH ;initialize RCAP2H register
mov RCAP2L,#AFH ;intialize RCAP2L register
orl IE,#AOH ;enable Timer 2 interrupt
forever: mov ov_cnt,#20 ;initialize the timer overflow count to 20

here: mov A,ov_cnt ;wait until 1 s is over
jnz here ;"
inc second ;increment the second
cjne second,#60, forever ;need to update minute?
mov second,#0 ;reset secont to 0
inc minute ;increment the minute
cjne minute,#60, forever ;need to update the hour
mov minute,#0 ;reset minute to 0
inc hour ;increment hour
cjne hour,#24,forever ;need to reset hour to 0?
mov hour,#0 ;reset hour to 0
ljmp forever ;repeat
end

List of 7 messages in thread
TopicAuthorDate
8051 12 hour clock            01/01/70 00:00      
   RE: 8051 12 hour clock            01/01/70 00:00      
      RE: 8051 12 hour clock            01/01/70 00:00      
   Tautology            01/01/70 00:00      
      RE: Tautology - Andy            01/01/70 00:00      
         RE: Technical Literature            01/01/70 00:00      
   RE: 8051 12 hour clock            01/01/70 00:00      

Back to Subject List