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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/13/04 05:56
Read: times


 
#75863 - RE: 8052 - Timer2
Responding to: ???'s previous message
If I didn't make clear why big ADJ is a bad thing...
Together with the ADJ value, a sequence of code of corresponding length must follow, and the sequence must not be overridable/breakable/pause'able - if it's 10 cycles it must be 10 cycles, no 5-cycle interrupt may kick in in the meantime. So for the duration of this sequence you must disable/override (by priority) all the other interrupts, thus other, possibly important things won't be served. (suddenly the timer duties that were handled by independent low-level hardware are handled to software so any change in timing will break the clock value). It's pretty obvious we should keep this period as short as possible so others wouldn't wait. So, i.e. we can keep the interrupt on high level, but if we have a lot to do in the interrupt, we can drop the interrupt flag as soon as we finish the time-critical section.

INT_HIGHPRI:
PUSH PSW
PUSH ACC
MOV TH0,#HIGH -TID0
MOV A,TL0 ADD A,#(LOW -TID0) + ADJ
MOV TL0,A 
PUSH INT_LOWPRI_LO
PUSH INT_LOWPRI_HI  ; or was that HI, LO?
RETI ; Jump to INT_LOWPRI, drop interrupt flag.

INT_LOWPRI:  ; You should earlier store the address of this in RAM under INT_LOWPRI_LO,_HI 

; Everything here happens on main program priority level (all other interrupts may kick in)
; Increment your 0.01s counter
; Check if ==100, increment seconds, reset
; Perform time calculation, update display
; Perform all the other RTC-related operations you want

POP ACC
POP PSW
RET ; return from the interrupt...


List of 19 messages in thread
TopicAuthorDate
8052 - Timer2            01/01/70 00:00      
   RE: 8052 - Timer2            01/01/70 00:00      
      RE: 8052 - Timer2            01/01/70 00:00      
   RE: 8052 - Timer2            01/01/70 00:00      
      RE: 8052 - Timer2            01/01/70 00:00      
         RE: 8052 - Timer2            01/01/70 00:00      
         RE: 8052 - Timer2            01/01/70 00:00      
      RE: 8052 - Timer2            01/01/70 00:00      
         RE: 8052 - Timer2            01/01/70 00:00      
   RE: 8052 - Timer2            01/01/70 00:00      
      RE: 8052 - Timer2            01/01/70 00:00      
         RE: 8052 - Timer2            01/01/70 00:00      
            RE: 8052 - Timer2            01/01/70 00:00      
               RE: 8052 - Timer2            01/01/70 00:00      
                  RE: 8052 - Timer2            01/01/70 00:00      
                     RE: 8052 - Timer2            01/01/70 00:00      
                        RE: 8052 - Timer2            01/01/70 00:00      
                           RE: 8052 - Timer2            01/01/70 00:00      
                  RE: 8052 - Timer2            01/01/70 00:00      

Back to Subject List