STM32F401RE Nucleo板,无法切换用户LED

God*_*ped 1 c microcontroller stm32 stm32f4 nucleo

我试图弄清楚如何在Nucleo板上切换LED,我只是看不到用户LED切换.在网上看来,这就是你要做的一切.还有其他人遇到过这个问题吗?

#include "stm32f4xx.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"

int main(void)
{
    int counter = 0;
    SystemInit();

    GPIO_InitTypeDef temp;
    temp.GPIO_Mode = GPIO_Mode_OUT;
    temp.GPIO_OType = GPIO_OType_PP;    // Push Pull
    temp.GPIO_Pin = GPIO_Pin_5;
    temp.GPIO_Speed = GPIO_Low_Speed;
    temp.GPIO_PuPd = GPIO_PuPd_NOPULL;

    RCC_APB2PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

    GPIO_Init( GPIOA, &temp );

    while( 1 )
    {
        if ( counter++ > 10000 )
        {
            GPIO_ToggleBits( GPIOA, GPIO_Pin_5 );
            counter = 0;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

小智 5

你必须写

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
Run Code Online (Sandbox Code Playgroud)

为了启用GPIOA.