stm32流水灯程序编写成功,却无法实现点灯,求指出问题

stm32流水灯程序编写成功,却无法实现点灯,求指出问题

问题描述:

学习点灯,写了一个编译成功的程序,但无法实现点灯,以下是程序:
main.c

#include "stm32f10x.h"
#include "led.h"

#define SOFT_Delay Delay(0xFFFFF);
void Delay(__IO u32 nCount);
int main(void)
{
    LED_GPIO_Config();
    
    while(1)
    {
      GPIO_SetBits(LED1_GPIO_PORT, LED1_GPIO_Pin);
        GPIO_SetBits(LED3_GPIO_PORT, LED3_GPIO_Pin);
        GPIO_ResetBits(LED2_GPIO_PORT, LED2_GPIO_Pin);
    SOFT_Delay;
      
        GPIO_SetBits(LED1_GPIO_PORT, LED1_GPIO_Pin);
        GPIO_SetBits(LED2_GPIO_PORT, LED2_GPIO_Pin);
        GPIO_ResetBits(LED3_GPIO_PORT, LED3_GPIO_Pin);
        SOFT_Delay;
     
        GPIO_SetBits(LED2_GPIO_PORT, LED2_GPIO_Pin);
        GPIO_SetBits(LED1_GPIO_PORT, LED1_GPIO_Pin); 
        GPIO_ResetBits(LED3_GPIO_PORT, LED3_GPIO_Pin); 
        SOFT_Delay;
      
    
    }
        
    
} 

void Delay(__IO uint32_t nCount)
{
for(;nCount!=0;nCount--);
}


led.h

#ifndef __LED_H
#define __LED_H


#include "stm32f10x.h"


#define LED1_GPIO_Pin   GPIO_Pin_5
#define LED1_GPIO_PORT  GPIOB
#define LED1_GPIO_CLK   RCC_APB2Periph_GPIOB

#define LED2_GPIO_Pin   GPIO_Pin_0
#define LED2_GPIO_PORT  GPIOB
#define LED2_GPIO_CLK   RCC_APB2Periph_GPIOB

#define LED3_GPIO_PORT  GPIOB
#define LED3_GPIO_CLK   RCC_APB2Periph_GPIOB
#define LED3_GPIO_Pin   GPIO_Pin_1


 

 

void LED_GPIO_Config(void);

#endif


led.c

#include "led.h"

void LED_GPIO_Config(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;
  RCC_APB2PeriphResetCmd(LED1_GPIO_CLK|LED2_GPIO_CLK|LED3_GPIO_CLK,ENABLE);
    GPIO_InitStructure.GPIO_Pin=LED1_GPIO_Pin;
    GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
    GPIO_Init(LED1_GPIO_PORT,&GPIO_InitStructure);
    GPIO_InitStructure.GPIO_Pin=LED2_GPIO_Pin;
    GPIO_Init(LED2_GPIO_PORT,&GPIO_InitStructure);
    GPIO_InitStructure.GPIO_Pin=LED3_GPIO_Pin;
    GPIO_Init(LED3_GPIO_PORT,&GPIO_InitStructure);
     

}


编译是没有问题的,但是烧录到板子上却无法实现点灯,求指导一下到底是为什么?

main函数先这样改,看程序有没有跑起来,反正就是让灯全部亮,至于是拉高亮还是拉低亮就自己看看原理图。如果灯没亮可能程序没跑起来,建议拿一个可以运行的模板,然后替换自己的代码上去

int main(void)
{
    LED_GPIO_Config();
      GPIO_SetBits(LED1_GPIO_PORT, LED1_GPIO_Pin);
        GPIO_SetBits(LED3_GPIO_PORT, LED3_GPIO_Pin);
        GPIO_SetBits(LED2_GPIO_PORT, LED2_GPIO_Pin);
    while(1)
    {
    }
} 


LED_GPIO_Config里面GPIO_Init(LED1_GPIO_PORT,&GPIO_InitStructure)三次都给的一个指针没问题吗