问题:
解决:
MD5 + stm32f10x
查最小系统原理图得知 板载LED脚为PB12
使用MD5创建好系统后 勾选 GPIO & RCC ,代码如下
结果为灯约亮0.5s灭2s
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include "stm32f10x_conf.h" #include "stm32f10x_rcc.h" void delay_ms(u16 c){ u16 i=0; while(c--){ i=12000; while(i--); } } int main(void){ GPIO_InitTypeDef g; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE); g.GPIO_Pin=GPIO_Pin_12; g.GPIO_Speed=GPIO_Speed_2MHz; g.GPIO_Mode=GPIO_Mode_Out_PP; GPIO_Init(GPIOB,&g); while(1){ GPIO_WriteBit(GPIOB,GPIO_Pin_12,Bit_RESET); delay_ms(500); GPIO_WriteBit(GPIOB,GPIO_Pin_12,Bit_SET); delay_ms(2000); } } |