STM32F407 库开发 LED 灯 外部时钟没开启 程序进入循环 求教啊!

2019-07-21 05:08发布

LED函数:
#include "stm32f4xx.h"
#include "led.h"
//#include "stm32f4xx_gpio.h"
//#include "stm32f4xx_rcc.h"
void LED_GPIO_Config(void)
{
GPIO_InitTypeDef GPIO_InitStruct;

RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOB,ENABLE);

GPIO_InitStruct.GPIO_Pin= GPIO_Pin_5;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;

/*GPIO_InitStruct.GPIO_Pin= GPIO_Pin_5;
GPIO_Init(GPIOB,&GPIO_InitStruct);*/

GPIO_InitStruct.GPIO_Pin= GPIO_Pin_6;
GPIO_Init(GPIOB,&GPIO_InitStruct);
//GPIO_SetBits(GPIOB, GPIO_Pin_5 | GPIO_Pin_6);  
}
#include "stm32f4xx.h"
//#include "stm32f4xx_gpio.h"
#include "led.h"
static void Delay(__IO uint32_t nCount);
//void LED_GPIO_Config(void);
main函数:
int main(void)
{
RCC->CR = 0X00010000;
LED_GPIO_Config();
while(1)
{

GPIO_ResetBits(GPIOB,GPIO_Pin_5);
Delay(0x1fffff);
GPIO_SetBits(GPIOB,GPIO_Pin_5);
Delay(0x1fffff);
GPIO_ResetBits(GPIOB,GPIO_Pin_6);
Delay(0x1fffff);
GPIO_SetBits(GPIOB,GPIO_Pin_6);
Delay(0x1fffff);
}

}
static void Delay(__IO uint32_t nCount)
{
  while(nCount--)
  {
  }
}
然后就这样了,如下:
 /* Wait till HSE is ready and if Time out is reached exit */
  do
  {
    HSEStatus = RCC->CR & RCC_CR_HSERDY;
    StartUpCounter++;
  } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
调试时一直在这里死循环,那位大神指导指导。




友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
3条回答
正点原子
1楼-- · 2019-07-21 05:55
说明外部时钟一直没有准备好...
godsend
2楼-- · 2019-07-21 10:06
RCC->CR = 0X00010000;这是什么?为何不用SystemInit();
要不然你把那句删掉试试
天使的诺言
3楼-- · 2019-07-21 15:40
回复【2楼】正点原子:
------------------------
原子哥,是我粗心大意了 ,系统时钟配置的超频了。额!重新配置好就ok了。

一周热门 更多>