BS2824 Holtek Semiconductor Inc., BS2824 Datasheet - Page 63

no-image

BS2824

Manufacturer Part Number
BS2824
Description
Touch Key Mcu
Manufacturer
Holtek Semiconductor Inc.
Datasheet
Interrupts
Rev. 1.00
PWM Output Control
PWM Programming Example
The PWM outputs are pin-shared with I/O pins. To operate as a PWM output and not as an I/O pin,
the correct bits must be set in the CTRL0 register. A zero value must also be written to the
corresponding bit in the I/O port control register to ensure that the corresponding PWM output pin is
setup as an output. After these two initial steps have been carried out, and of course after the required
PWM value has been written into the PWMn register, writing a high value to the corresponding bit in
the output data register will enable the PWM data to appear on the pin. Writing a zero value will
disable the PWM output function and force the output low. In this way, the Port data output registers
can be used as an on/off control for the PWM function. Note that if the CTRL0 register has selected
the PWM function, but a high value has been written to its corresponding bit in the PAC or PCC
control register to configure the pin as an input, then the pin can still function as a normal input line,
with pull-high resistor options.
The following sample program shows how the PWM0 output is setup and controlled.
Interrupts are an important part of any microcontroller system. When an external event or an internal
function such as a Timer/Event Counter or Time Base requires microcontroller attention, their
corresponding interrupt will enforce a temporary suspension of the main program allowing the
microcontroller to direct attention to their respective needs.
The devices contain a single external interrupt and multiple internal interrupts. The external
interrupt is controlled by the action of the external interrupt pin, while the internal interrupt is
controlled by the Timer/Event Counters and Time Base overflows.
mov
mov
set
set
clr
set
: :
clr
a,64h
pwm0,a
ctrl0.5
ctrl0.3
pac.4
pa.4
pa.4
; setup PWM value of decimal 100
; select the 7+1 PWM mode
; select pin PA4 to have a PWM function
; setup pin PA4 as an output
; enable the PWM output
; disable the PWM output_ pin
; PA4 forced low
Interrupt Scheme
63
BS2824/BS2854/BS2868
Touch Key MCU
January 27, 2010

Related parts for BS2824