OKI单片机——ML610Q4XX Melody Driver
配置流程:
(1) Select a buzzer mode by setting the BZMD bit of the melody 0 control register (MD0CON) to “1”.
(MD0CON寄存器的BZMD位置一)。
(2) Select a buzzer output mode using the melody 0 tempo code register (MD0TMP).
(设置旋律节奏编码寄存器MD0TMP)。
(3) Select a duty of the High level width of the buzzer output waveform using the melody 0 tone length code register(MD0LEN).
(设置Buzzer高电平宽度和波形长度寄存器MD0LEN)。
(4) Set the buzzer output frequency in the melody 0 scale code register (MD0TON).
(设置波形输出频率寄存器MD0TON)。
(5)Set bit 2 (ENMLT) of the frequency control register 1(FCON1) to “1” to enable the low-speed double clock.
(频率控制寄存器1FCON1的ENMLT位置1,使能低速时钟(32K×2))。
(6) When the M0RUN bit of the melody 0 control register (MD0CON) is set to “1”, the waveform equivalent to the buzzer sound that is set from the MD0 pin is output.
(旋律控制寄存器MD0CON的M0RUN位置1,波形通过MD0脚输出)。
/***********************************************/
* @brief 输出4K频率的方波
* @details
/***********************************************/
void Buzzer_Mode(void)
{
//--配置P50--//
P50DIR = 0;//P50 pin: Output (initial value)
P50C0 = 1;//P50 pin: In CMOS output mode
P50MD1 = 0;//Melody 0 output
P50MD0 = 1;
BZMD = 1;//Buzzer mode
MD0TMP = 0X03;//Continuous sound output;连续输出
MD0LEN = 8; // 8/16 Duty
MD0TON = 0X00; // 4.096 kHz (initial value)
ENMLT = 1; // 32.767K X 2
M0RUN = 1;//Starts MD0 output.
}