X - 5
Chapter 10 Buzzer
Operation
10-3-2 Setup Example
Buzzer outputs the square wave of 2 kHz from P06 pin. It is used 8.38 MHz as the high oscillation clock
(fosc).
An example setup procedure, with a description of each step is shown below.
(1) Set the BUZS2-0 flag of the oscillation
stabilization wait control register (DLYCTR) to
"010" to select fosc/2
12
to the buzzer
frequency.
When the high oscillation clock fosc is 8.38
MHz, the buzzer output frequency is 2.05 kHz.
(2) Set the output data P0OUT6 of P06 pin to "0",
and set the direction control P0DIR6 of P06 pin
to "1" to select output mode.
P06 pin outputs low level.
(3) Set the BUZOE flag of the oscillation
stabilization wait control register (DLYCTR) to
"1" to output the square wave of the buzzer
output frequency set by P06 pin.
(4) Set the BUZOE flag of the oscillation
stabilization wait control register (DLYCTR) to
"0" to clear, and P06 pin outputs low level.
Setup Procedure
(1) Set the buzzer frequency.
DLYCTR (x'3F4D')
bp6-4 : BUZS2-0 = 010
(2) Set P06 pin.
P0OUT (x'3F10')
bp6 : P0OUT6 = 0
P0DIR (x'3F30')
bp6 : P0DIR6 = 1
(3) Buzzer output ON.
DLYCTR (x'3F4D')
bp7 : BUZOE = 1
(4) Buzzer output OFF.
DLYCTR (x'3F4D')
bp7 : BUZOE = 0
Description