我正在尝试弄清楚如何切换 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;
}
}
}
最佳答案
你必须写
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
为了启用 GPIOA。
关于c - STM32F401RE Nucleo 板,无法切换用户 LED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51220353/