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

no-image

SAB80C517-M16

Manufacturer Part Number
SAB80C517-M16
Description
8-Bit CMOS Single-Chip Microcontroller
Manufacturer
SIEMENS [Siemens Semiconductor Group]
Datasheet
– Compare Setup
Compare mode
Compare register CM0 (consisting of CMH0 and CML0) is used in compare mode 0. This means bit
CMSEL.0 must be set (in register CMSEL) to assign CM0 to the compare timer and switch on
compare mode 0.
Enable port output
The compare is enabled with SFR bit CMEN.0 in register CMEN. The corresponding compare
output pin is port 4.0.
– Interrupts
Since the compare value may be varied in every compare timer period, it is most effective to use
the compare timer overflow interrupt for reloading the compare register CM0 with a new value.
Enable Interrupt
The compare timer overflow interrupt is enabled by SFR bit ECT in register IEN2. The general
enable flag EAL in register IEN0 must be set, too.
The Program
Variation of the duty cycle of the PWM signal is done by a variation of the contents of the compare
register CM0. CM0 is loaded with new compare values in an (high prioritized) interrupt routine. This
makes the loading independent from other tasks running on the CPU.
The new compare values are loaded by a cyclic look-up table routine. The table is located in the
ROM and contains the compare values for every sample point. (In our case the sine-wave is
synthesized by six sample points.)
The program flow is best described by a program flow chart (see figure 10-3). The following
paragraphs give some additional details.
– Main Program
CCU and interrupt initialization is done according to the previous description of the CCU
configuration.
There is no other task in this application to be done in the main program. The controller is free for
any other job (e.g. I/O, control algorithms, adapting the sine wave table, etc.).
– Interrupt Service Routine
The interrupt program contains the table look-up routine only. This routine is illustrated in
figure 10-3 and performs the following two little jobs:
Semiconductor Group
– managing the table pointer
– loading the CM0-register.
261
Application Examples

Related parts for SAB80C517-M16