程序:
#include “stm32f10x.h” // Device header
#include “delay.h”
int main(void)
{
/RCC->APB2ENR =0x00000010;
GPIOC->CRH=0x00300000;
GPIOC->ODR=0x00002000;寄存器操作方式/
RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOA,ENABLE);//RCC->APB2ENR =0x00000010;
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.GPIO_Mode =GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Pin =GPIO_Pin_All;
GPIO_InitStruct.GPIO_Speed =GPIO_Speed_50MHz;
GPIO_Init (GPIOA ,&GPIO_InitStruct);//GPIOC->CRH=0x00300000;
//GPIO_SetBits (GPIOA,GPIO_Pin_7);//GPIOC->ODR=0x00002000;
//GPIOC->ODR=0x00; 默认低电平
while(1)
{
GPIO_ResetBits (GPIOA,GPIO_Pin_7);
GPIO_SetBits (GPIOA,GPIO_Pin_6);
GPIO_ResetBits (GPIOA,GPIO_Pin_5);
Delay_ms(500);
GPIO_SetBits (GPIOA,GPIO_Pin_7);
GPIO_ResetBits (GPIOA,GPIO_Pin_6);
GPIO_SetBits (GPIOA,GPIO_Pin_5);
Delay_ms(500);
}
}
实现两灯0.5s交替闪烁并且蜂鸣器按照频率鸣叫