|
本帖最后由 sunsherry12 于 2017-3-31 10:56 编辑 采用的是stm32f4-std firmware\STM32F4xx_DSP_StdPeriph_Lib_V1.8.0\Project\STM32F4xx_StdPeriph_Templates 模板文件,谢谢高手们 #include "main.h" void delay(unsigned int us) {unsigned char n; while(us--); for(n=0;n<9;n++); } int main(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_14; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOB, &GPIO_InitStructure); while(1) { GPIO_SetBits(GPIOB,GPIO_Pin_7); GPIO_SetBits(GPIOB,GPIO_Pin_14); delay(200); GPIO_ResetBits(GPIOB,GPIO_Pin_7); GPIO_ResetBits(GPIOB,GPIO_Pin_14); } } |
微信公众号
手机版
嗯嗯谢谢哈!但是这个为啥就不行呢
刚试了应该不是这个原因,F4的时钟配置在system_stm32f4xx.c中要不要修改呢
错误的原因有一万种。用mx。
while(1)
{
GPIO_SetBits(GPIOB,GPIO_Pin_7);
GPIO_SetBits(GPIOB,GPIO_Pin_14);
HAL_Delay(200);
GPIO_ResetBits(GPIOB,GPIO_Pin_7);
GPIO_ResetBits(GPIOB,GPIO_Pin_14);
HAL_Delay(200);
}
}
这样改下试下
延时时间太短也是一方面....