板子:
STM32F4-DISCOVERY
LED部分原理图:
函数调用:
============main.c===============
#include "stm32f4xx.h"
#include "bsp_led.h"
int main(void)
{
LED_GPIO_Config();
//GPIO_ResetBits(LED_R_PORT,LED_R_PIN);
GPIO_SetBits(LED_R_PORT,LED_R_PIN);
while(1)
{
};
}
============bsp_led.h===============
#ifndef __BSP_LED_H__
#define __BSP_LED_H__
//#include "stm32f4xx.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"
#define LED_R_PIN GPIO_Pin_13
#define LED_R_PORT GPIOG
#define LED_R_CLK RCC_AHB1Periph_GPIOG
void LED_GPIO_Config(void);
#endif
=============bsp_led.c==============
#include "bsp_led.h"
void LED_GPIO_Config(void)
{
GPIO_InitTypeDef* GPIO_Init_Pin;
//时钟
RCC_AHB1PeriphClockCmd(LED_R_CLK,ENABLE);
GPIO_Init_Pin->GPIO_Pin = LED_R_PIN;
GPIO_Init_Pin->GPIO_Mode = GPIO_Mode_OUT;
GPIO_Init_Pin->GPIO_Speed = GPIO_Fast_Speed;
GPIO_Init_Pin->GPIO_OType = GPIO_OType_PP;
GPIO_Init_Pin->GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(LED_R_PORT,GPIO_Init_Pin);
}
运行keil没编译出错的提示,但是烧到板子就是点不亮PG13对应的LED灯。
时钟起来了。跟正常能点亮的程序对比过。结果发现这个问题。
一周热门 更多>