345
CHAPTER 15 BUZZER OUTPUT
15.5 Program Example for Buzzer Output
This section shows an program example for buzzer output.
■ Program Example for Buzzer Output
● Processing specification
Suppose that the buzzer output of 3.052 kHz is output to the BZ pin and then the buzzer output is cut off.
If 2
12
/F
CH
is selected when the oscillation (F
CH
) is 12.5 MHz, the buzzer output frequency is calculated as
follows:
Buzzer output frequency: 12.5 MHz/2
12
= 12.5 MHz/4096 = 3.052 kHz
● Coding example
BZCR EQU 0018H ; Address of the buzzer register
;-------------------Main program-----------------------------------------------------------------
CSEG ; [CODE SEGMENT]
:
MOV BZCR,#00000010 ; Buzzer output on (3.052 kHz / Oscillation of 12.5 MHz)
:
:
:
MOV BZCR,#00000000 ; Buzzer output off (I/O port or PPG output)
:
:
ENDS
; ----------------------------------------------------------------------------------------------------------
END