Prescaler
Bits T0PSC0~T0PSC2 of the TMR0C or TPSC0~TPSC2 of the TMRC register can be used to define
a division ratio for the internal clock source of the 8-bit Timer/Event Counter enabling longer time out
periods to be setup.
PFD Function
The Programmable Frequency Divider provides a means of producing a variable frequency output
suitable for applications, such as piezo-buzzer driving or other interfaces requiring a precise frequency
generator.
As the pins are shared with I/O pins, the function is selected using the TMR1C register.
The Timer/Event Counter 1 overflow signal is the clock source for the PFD function. The output
frequency is controlled by loading the required values into the timer registers to give the required
division ratio. The counter will begin to count-up from this preload register value until full, at which
point an overflow signal is generated, causing the PFD outputs to change state. The counter will then
be automatically reloaded with the preload register value and continue counting-up.
If the TMR1C register has selected the PFD function, it is essential for the Port E control register PEC,
to setup the PFD pin as output. The bit PE0 must be set high to activate the PFD. The output data bit
can be used as the on/off control bit for the PFD outputs. Note that the PFD output will all be low if the
output data bit is cleared to zero.
Using this method of frequency generation, and if a crystal oscillator is used for the system clock, very
precise values of frequency can be generated.
I/O Interfacing
The Timer/Event Counter, when configured to run in the event counter or pulse width capture mode,
requires the use of an external timer pin for its operation. As this pin is a shared pin it must be
configured correctly to ensure that it is setup for use as a Timer/Event Counter input pin. This is
achieved by ensuring that the mode select bits in the Timer/Event Counter control register select either
the event counter or pulse width capture mode. Additionally the corresponding Port Control Register
bit must be set high to ensure that the pin is setup as an input. Any pull-high resistor connected to this
pin will remain valid even if the pin is used as a Timer/Event Counter input.
Programming Considerations
When configured to run in the timer mode, the internal system clock is used as the timer clock source
and is therefore synchronised with the overall operation of the microcontroller. In this mode when the
appropriate timer register is full, the microcontroller will generate an internal interrupt signal directing
the program flow to the respective internal interrupt vector. For the pulse width capture mode, the
internal system clock is also used as the timer clock source but the timer will only run when the correct
logic condition appears on the external timer input pin. As this is an external event and not
synchronised with the internal timer clock, the microcontroller will only see this external event when
BS83B08-3/B12-3/B16-3/B16G-3/C24-3
8-Bit Touch Key Flash MCU
Rev. 1.50
73
April 28, 2020
T i m e r O v e r f l o w
P F D C l o c k
P E 0 D a t a
P F D O u t p u t a t P E 0
PFD Function