SAB80C517-M16 SIEMENS [Siemens Semiconductor Group], SAB80C517-M16 Datasheet - Page 255

no-image

SAB80C517-M16

Manufacturer Part Number
SAB80C517-M16
Description
8-Bit CMOS Single-Chip Microcontroller
Manufacturer
SIEMENS [Siemens Semiconductor Group]
Datasheet
10
10.1
10.1.1 Generation of Two Different PWM Signals with "Additive Compare" using the
The following example gives an idea of how to use compare mode 1 and compare interrupts for an
"additive pulse width modulation".
Assume that an application requires two PWM signals at two port pins providing different switching
frequencies, e.g. a switching frequency of 2 kHz at port 1.1 (further on called PWM channel 1) and
5 kHz at port 1.2 (further on called PWM channel 2).
In this case compare mode 0 cannot be used since it uses the timer overflow signal to switch all
compare outputs to low level and thereby provides the same switching frequency. In our case,
however, the period of each PWM signal is different, being 0.5 ms for signal 1 ( 500 timer 2 counts
at
Thus compare mode 1 must be used, because in this mode both transitions can be preset by
software.
Timer 2 may run with its full period from 0000, overflowing at a count rate of 65.535 ( 0FFFF H ).
External interrupts INT4 and INT5 are enabled as compare interrupts and the compare registers
CC1 and CC2 are initialized to 50 % duty cycle thus containing a value of 250 and 100, respectively.
The contents of the port latches must be preprogrammed to a complementary level which will
appear after the corresponding compare event.
Now timer 2 is started. The first compare interrupt occurs after 100 timer increments caused by the
contents of register CC2.
Figure 10-1 illustrates the task schedule of the program. Every compare event causes an interrupt
request, which is served after a certain response time (depending on the current task being in
progress). There are a few jobs to be done, which are described in the following.
Semiconductor Group
f
OSC
= 12 MHz) and 0.2 ms for signal 2 ( 200 counts).
Application Examples
Application Examples for the Compare Functions
"CCx Registers"
^
256
Application Examples
^
^

Related parts for SAB80C517-M16