刚接触STM32,我的硬件是自己设计的,用的是STM32F405简化了一个跑马灯列程作用只需要将PD2设置为高或者低的小程序。程序烧录进去后,单片机完全没有反应!!
#include "stm32f4xx.h"
#include "sys.h"
#include "delay.h"
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_SetBits(GPIOD,GPIO_Pin_1 | GPIO_Pin_2);
}
int main(void)
{
delay_init(168);
LED_Init();
while(1)
{
GPIO_ResetBits(GPIOD,GPIO_Pin_2);
GPIO_SetBits(GPIOD,GPIO_Pin_1);
delay_ms(500);
GPIO_SetBits(GPIOD,GPIO_Pin_2);
GPIO_ResetBits(GPIOD,GPIO_Pin_1);
delay_ms(500);
}
}
我测量单片机各个电源输入ok,晶振输入ok,复位ok。我用的是24MHZ的有源晶振,只用了一个时钟输入脚。需要更改函数配置么?
看了好几个列程主函数里都没初始化时钟函数,是采用的默认么??还是哪里配置了我没有发现??
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
程序在进入main之前,悄悄地干了不少事。
查system.c函数,里面晶体常数要修改为24M。
估计是这问题。
一周热门 更多>