标题: STM32固件库LED不能关灯,请指教一下 [打印本页]

作者: 陈都cd    时间: 2020-11-18 10:35
标题: STM32固件库LED不能关灯,请指教一下
main.c:#include "stm32f10x.h"
#include "bsp_led.h"


int main()
{
        LED_GPIO_Configure();
        
        
        GPIO_SetBits(LED_GPIO_Port,LED_GPIO_Pin);
        
        return 0;
}






bsp_led.c:
#include "bsp_led.h"


void LED_GPIO_Configure(void)
{
        GPIO_InitTypeDef GPIO_InitStruct;
        
        RCC_APB2PeriphClockCmd(LED_GPIO_CLK,ENABLE);
        
        GPIO_InitStruct.GPIO_Pin                        =                        LED_GPIO_Pin;
        GPIO_InitStruct.GPIO_Mode                        =                        GPIO_Mode_AF_PP;
        GPIO_InitStruct.GPIO_Speed                =                        GPIO_Speed_50MHz;
        
        GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);
}




bsp_led.h:
#ifndef __BSP_LED_H__
#define __BSP_LED_H__


#include "stm32f10x.h"


#define LED_GPIO_Pin                        GPIO_Pin_1
#define LED_GPIO_Port                        GPIOB
#define LED_GPIO_CLK                        RCC_APB2Periph_GPIOB


void LED_GPIO_Configure(void);


#endif /* __BSP_LED_H__ */



我刚学STM32的固件库,为什么关不了灯,请大神指点一下

作者: 压着我头发啦    时间: 2020-11-18 13:24
GPIO_SetBits(LED_GPIO_Port,LED_GPIO_Pin);主函数就一条点灯程序,肯定不会关灯啊,没有关灯的语句
作者: 陈都cd    时间: 2020-11-18 13:39
低电平点灯,我在IO口设置输出模式时,不小心弄成了复用
作者: chenyinhu    时间: 2020-11-19 09:00
GPIO_SetBits(LED_GPIO_Port,LED_GPIO_Pin);set好像是置1吧,主函数中也没有死循环吧




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1