??? 05/14/05 07:15 Read: times |
#93411 - pwm isr |
On an AT89S52 @ 11.05MHz, assuming that timer2 is free and set to 16-bit auto-reload mode @ 1KHz.
1. Will the following routine impose considerable overload on the CPU?(The CPU is not very busy at all i.e. don't ask me to define "considerable") 2. If not, is there any other reason to migrate to a derivative with PCA?(In this very situ for a one chennel fixed-freq. PWM and when no synchronization is needed) The duty cycle is passed to the routine through ON_TIME variable: MOV ON_TIME,#somethin(0..255) ;---------------------------------------------------------------------------------------; ; TIMER2 ROUTINE ; ;---------------------------------------------------------------------------------------; TIMER2ISR: PUSH PSW ;CJNE changes PSW PUSH ACC ;ACC is used in this ISR MOV A,ON_TIME ; CJNE A,TH2,$+3 ;Just to set/clear carry MOV Px.y,/C ; POP ACC ;Retrive ACC POP PSW ;Restore PSW RETI ;Return and restore interrupt logic *If TH2(a 0..255 counter) < ACC(needed ON time) then OFF else ON No matter TH2 runs very much fast, No matter each consecutive access/reference to TH2 in the CJNE instruction may not read the "next" successive value of TH2, enough to know that TH2 is statistically less than 128 at 50% of accesses to it, no need for "on the fly" reading of TH2... |
Topic | Author | Date |
pwm isr | 01/01/70 00:00 | |
2%![]() | 01/01/70 00:00 |