Rev. 1.20
82
�an�a�� 2�� 201�
Rev. 1.20
8�
�an�a�� 2�� 201�
BS82B12A-3/BS82C16A-3/BS82D20A-3
Touch Key 8-Bit Flash MCU with LED/LCD Driver
BS82B12A-3/BS82C16A-3/BS82D20A-3
Touch Key 8-Bit Flash MCU with LED/LCD Driver
Timer/Counter Mode
To select this mode, bits C
T
0M1 and C
T
0M0 in the C
TM
0C1 register should be set to 11
respectively. The Timer/Counter Mode operates in an identical way to the Compare Match Output
Mode generating the same interrupt flags. The exception is that in the Timer/Counter Mode the
C
TM
0 output pin is not used. Therefore the above description and Timing Diagrams for the
Compare Match Output Mode can be used to understand its function. As the C
TM
0 output pin is not
used in this mode, the pin can be used as a normal I/O pin or other pin-shared function.
PWM Output Mode
To select this mode, bits C
T
0M1 and C
T
0M0 in the C
TM
0C1 register should be set to 10
respectively. The PWM function within the C
TM
0 is useful for applications which require functions
such as motor control, heating control, illumination control etc. By providing a signal of fixed
frequency but of varying duty cycle on the C
TM
0 output pin, a square wave AC waveform can be
generated with varying equivalent DC RMS values.
As both the period and duty cycle of the PWM waveform can be controlled, the choice of generated
waveform is extremely flexible. In the PWM mode, the C
T
0CCLR bit has no effect on the PWM
operation. Both of the CCRA and CCRP registers are used to generate the PWM waveform, one
register is used to clear the internal counter and thus control the PWM waveform frequency, while
the other one is used to control the duty cycle. Which register is used to control either frequency
or duty cycle is determined using the C
T
0DPX bit in the C
TM
0C1 register. The PWM waveform
frequency and duty cycle can therefore be controlled by the values in the CCRA and CCRP registers.
An interrupt flag, one for each of the CCRA and CCRP, will be generated when a compare match
occurs from either Comparator A or Comparator P. The C
T
0OC bit In the C
TM
0C1 register is used
to select the required polarity of the PWM waveform while the two C
T
0IO1 and C
T
0IO0 bits are
used to enable the PWM output or to force the C
TM
0 output pin to a fixed high or low level. The
C
T
0POL bit is used to reverse the polarity of the PWM output waveform.
CTM, PWM Mode, Edge-aligned Mode, CT0DPX=0
CCRP
001b
010b
011b
100b
101b
110b
111b
000b
Pe�iod
128
2�6
�84
�12
640
768
896
1024
D�t�
CCRA
If f
SYS
= 16MHz, C
TM
0 clock source is f
SYS
/4, CCRP = 100b, CCRA =128,
The C
TM
0 PWM output frequency = (f
SYS
/4) / 512 = f
SYS
/2048 = 7.8125 kHz, duty = 128/
512
= 25%.
If the Duty value defined by the CCRA register is equal to or greater than the Period value, then the
PWM output duty is 100%.
CTM, PWM Mode, Edge-aligned Mode, CT0DPX=1
CCRP
001b
010b
011b
100b
101b
110b
111b
000b
Pe�iod
CCRA
D�t�
128
2�6
�84
�12
640
768
896
1024
The PWM output period is determined by the CCRA register value together with the C
TM
0 clock
while the PWM duty cycle is defined by the CCRP register value.