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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/14/05 07:53
Modified:
  05/14/05 08:06

Read: times


 
#93413 - 2%
Responding to: ???'s previous message
Payam Soltany said:
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...

Let's estimate real quick. So, your ISR runs 1000 times a second, and probably uses about 20 machine cycles. That's 20000 machine cycles a second for your ISR. You have just under one million machine cycles a second available. Thus, it seems to me you're probably using about 2% of your CPU for this.

In the end though, you have to decide whether or not this is ok. If you have other timing-critical code that could be disturbed by this ISR, or if you have a higher priority interrupt that could disturb this ISR, overall long term CPU utilization might not matter much in comparison to meeting your system's timing constraints.

--Sasha Jevtic

List of 2 messages in thread
TopicAuthorDate
pwm isr            01/01/70 00:00      
   2%            01/01/70 00:00      

Back to Subject List