A: First buzzer registers are written and marquees and the like on a simple input-output GPIO port
1. Enable IO port
2. Initialize the IO port mode, write BEEP_Init ();
3. The IO port operation, the high and low output
II: Operation
Analysis and PB port enabled first, then initialize the IO port
BEEP.h #include void BEEP_Init ( void ) { the RCC -> APB2ENR | = . 1 << . 3 ; GPIOB -> the CRL = & 0XFFFFFFFF0 ; // clear 0 GPIOB -> the CRL | = 0XFFFFFFFF3 ; // initialize BEEP = 0 ; // Close buzzer output }
BEEP = 0 ** ;?
/ Close buzzer output
The main function
main() { Stm32_Clock_Init(9); delay_Init(72); BEEP_Init(); while(1) { BEEP=0;delay_ms(300); BEEP=0;delay_ms(300); } }