Generating A Low-Speed Pwm Output - Intel 8XC196K Series User Manual

Table of Contents

Advertisement

8XC196K x , J x , CA USER'S MANUAL
10.4.2.1

Generating a Low-speed PWM Output

You can generate a low-speed, pulse-width modulated output with a single EPA channel and a
standard interrupt service routine. Configure the EPA channel as follows: compare mode, toggle
output, and the compare function re-enabled. Select standard interrupt service, enable the EPA
interrupt, and globally enable interrupts with the EI instruction. When the assigned timer/counter
value matches the value in the event-time register, the EPA toggles the output pin and generates
an interrupt. The interrupt service routine loads a new value into EPAx_TIME.
The maximum output frequency depends upon the total interrupt latency and the interrupt-service
execution times used by your system. As additional EPA channels and the other functions of the
microcontroller are used, the maximum PWM frequency decreases because the total interrupt la-
tency and interrupt-service execution time increases. To determine the maximum, low-speed
PWM frequency in your system, calculate your system's worst-case interrupt latency and worst-
case interrupt-service execution time, and then add them together. The worst-case interrupt la-
tency is the total latency of all the interrupts (both normal and PTS) used in your system. The
worst-case interrupt-service execution time is the total execution time of all interrupt service rou-
tines and PTS routines.
The following example shows the calculations for a system that uses a single EPA channel, a sin-
gle enabled interrupt, and the following interrupt service routine.
;If EPA0-3 interrupt is generated
EPA0-3_ISR:
PUSHA
LD EPA x _CON, #toggle_command
ADD EPA x _TIME, TIMER x , [next_duty_ptr]; Load next event time
POPA
RET
;If EPA x interrupt is generated from EPA4-9 interrupts
EPA x _ISR:
PUSHA
LD jtbase_ptr, #LSW jtbase1
LD epaipv_ptr, EPAIPV
TIJMP jtbase_ptr,[epaipv_ptr],7FH
;EPA4-9 service routines
EPA4-9_ISR:
PUSHA
LD EPA x _CON, #toggle_command
ADD EPA x _TIME,TIMER x ,[next_duty_ptr]
LJMP EPA x _DONE
EPA x _DONE:
POPA
RET
10-14
; Load contents of EPAIPV reg into ptr
; Jump to appropriate EPA ISR

Advertisement

Table of Contents
loading

Table of Contents