- 点灯程序
- #include "stm32f10x.h"// Device header
- int b;
- void Delay1000us(); //提前至抬头,防止未识别
- int main()
- {
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
- GPIO_InitTypeDef GPIO_InitStructure;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(GPIOC,&GPIO_InitStructure);//内部自带库文件活用
-
- for(b=0;b<=100;b++) //for循环控制闪烁一次PC13引脚闪烁一次
- {
- GPIO_ResetBits(GPIOC,GPIO_Pin_13);
- Delay1000us();
- GPIO_SetBits(GPIOC,GPIO_Pin_13);
- //GPIO_ResetBits(GPIOC,GPIO_Pin_13);
- Delay1000us();}
- while(1)
- {
- }
-
- }
- void Delay1000us() //@11.0592MHz //延时函数
- {
- unsigned char i, j;
- i = 11;
- j = 190;
- do
- {
- while (--j);
- } while (--i);
- }
|