English
Language : 

CR16MCT9 Datasheet, PDF (59/153 Pages) National Semiconductor (TI) – CR16MCT9/CR16MCT5/CR16HCT9/CR16HCT5 16-Bit Reprogrammable/ROM Microcontroller
16.1.1 Dual 8-bit PWM Mode
Each timer subsystem may be configured to generate two
fully independent PWM waveforms on the respective TIOx
pins. In this mode, the counter COUNTx is split and operates
as two independent 8-bit counters. Each counter increments
at the rate determined by the clock prescaler.
Each of the two 8-bit counters may be started and stopped
separately via the associated TxRUN bits. Once either of the
two 8-bit timers is running the clock prescaler starts counting.
Once the clock prescaler counter value matches the value of
the associated CxPRSC register field, COUNTx is incre-
mented.
The period of the PWM output waveform is determined by
the value of the PERCAPx register. The TIOx output starts at
the default value as pro-grammed via the IOxCTL.PxPOL bit.
Once the counter value reaches the value of the period reg-
ister PERCAPx, the counter is reset to 0016 upon the next
counter increment. Upon the following increment from 0016
to 0116, the TIOx output will change to the opposite of the de-
fault value.
The duty cycle of the PWM output waveform is controlled by
the DTYCAPx register value. Once the counter value reach-
es the value of the duty cycle register DTYCAPx, the PWM
output TIOx changes back to its default value upon the next
counter increment. Figure 19 illustrates this concept.
COUNTx
PERCAPx
DTYCAPx
0A
09
08
07
06
05
04
03
02
01
0A
09
08
07
06
05
04
03
02
01
00
00
TxRUN=1
TIOx (PxPOL=0)
TIOx (PxPOL=1)
Figure 19. VTU PWM generation
The period time is determined by the following formula:
PWMperiod = (PERCAPx + 1) * (CxPRSC + 1) * TCLK
The duty cycle in percent is calculated as follows:
DutyCycle[%] = (DTYCAPx / (PERCAPx+1)) *100
If the duty cycle register (DTYCAPx) holds a value which is
greater then the value held in the period register (PERCAPx)
the TIOx output will remain at the opposite of its default value
which corresponds to a duty cycle of 100%. If the duty cycle
register (DTYCAPx) register holds a value of 0016, the TIOx
output will remain at the default value which corresponds to
a duty cycle of 0%. In that case the value contained in the
PERCAPx register is irrelevant. This scheme allows the duty
cycle to be programmed in a range from 0% to 100%.
In order to allow fully synchronized updates of the period and
duty cycle compare values, the PERCAPx and DTYCAPx
registers are double buffered when operating in PWM mode.
Therefore if the user writes to either the period or duty cycle
register while either of the two PWM channels is enabled, the
new value will not take effect until the counter value matches
the previous period value or the timer is stopped.
Reading the PERCAPx or DTYCAPx register will always re-
turn the most recent value written to it.
The counter registers can be written if both 8-bit counters are
stopped. This allows the user to preset the counters before
starting and therefore generate PWM output waveforms with
a phase shift relative to one another. If the counter is written
with a value other then 0016 it will start incrementing from that
value while TIOx remains at its default value until the first
0016 to 0116 transition of the counter value occurs. If the
counter is preset to values which are smaller or equal then
the value held in the period register (PERCAPx) the counter
will count up until a match between the counter value and the
PERCAPx register value occurs. The counter will then be re-
set to 0016 and continue counting up. Alternatively the
counter may be written with a value which is greater then the
59
www.national.com