Programmable Frequency Divider (PFD) and Buzzer Application
Operating similar to a programmable frequency divider, the buzzer function within the
microcontroller provides a means of producing a variable frequency output suitable for applica
-
tions such as piezo-buzzer driving or other interfaces requiring a precise frequency generator.
All devices have this feature, and depending upon which device is chosen, offer either a single BZ
or complimentary BZ and BZ
pair of outputs. The function is selected via a configuration option,
however, if not selected, the pins can operate as normal I/O pins. Note that the BZ
pin is the in
-
verse of the BZ pin generating a kind of differential output and supplying more power to connected
interfaces such as buzzers.
The timer overflow signal is the clock source for the buzzer circuit. The output frequency is con-
trolled by loading the required values into the timer prescaler registers to give the required division
ratio. The counter, driven by the system clock which is divided by the prescaler value, will begin to
count-up from this preload register value until full, at which point an overflow signal is generated,
causing both the BZ and BZ
outputs to change state. The counter will then be automatically re-
loaded with the preload register value and continue counting-up. Refer to the relevant Timer/Event
Counters section for details of its settings and operations.
For the buzzer outputs to function, it is essential that the Port B control register PBC bit 0 and PBC
bit 1 are setup as outputs. If they are setup as inputs the buzzer output will not function, and used
as normal input pins. The BZ and BZ
outputs will only be activated if bit PB0 is set to ²1². This out
-
put data bit is used as the on/off control bit for the BZ and BZ
outputs. Note that the BZ and BZ out
-
puts will both be low if the PB0 output data bit is cleared to ²0². Note that the condition of bit PB1
has no effect on the overall control of the BZ and BZ
pins.
30
Cost-Effective I/O Type MCU
+ 1 + 2 + 3 + 4
T i m e r
E x t e r n a l T M R
P i n I n p u t
T O N ( w i t h T E = 0 )
P r e s c a l e r O u t p u t
( w i t h c l o c k = f
S Y S
)
I n c r e m e n t
T i m e r C o u n t e r
P r e s c a l e r O u t p u t i s s a m p l e d a t e v e r y f a l l i n g e d g e o f T 1 .
Pulse Width Measure Mode Timing Chart