我最近买了一个 STM-NUCLEO我正在尝试写入连接到 LED 的 PA0、PA1、PA2、PA3。连接到 PA0 和 PA1 的 LED 按预期点亮,但 PA2 和 PA3 没有。我用 PA4 试了一下,效果也不错。这是代码:
int main(void)
{
/* Configure the System clock to 84 MHz */
SystemClock_Config();
RCC->AHB1RSTR |= RCC_AHB1RSTR_GPIOARST; // resetting GPIOA
RCC->AHB1RSTR = 0; //exiting reset state
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; //enabeling GPIOA clock
GPIOA->MODER |= GPIO_MODER_MODER0_0;
GPIOA->MODER |= GPIO_MODER_MODER1_0;
GPIOA->MODER |= GPIO_MODER_MODER2_0;
GPIOA->MODER |= GPIO_MODER_MODER3_0;
//setting the pins
GPIOA->BSRR |= (1<<0);
GPIOA->BSRR |= (1<<1);
GPIOA->BSRR |= (1<<2);
GPIOA->BSRR |= (1<<3);
/* Add your application code here*/
/* Infinite loop */
while (1)
{
}
}
最佳答案
根据Nucleo schematics , PA2 & PA3 连接到内部 ST-Link Controller ,因此如果不先添加和删除一些桥接器,则不能用于 GPIO。
那是你的MCU,“SB62,SB63 Default open”表示连接不存在。
这是它连接到 ST-Link 接口(interface)的地方。
关于c - STM32 NUCLEO F401RE无法写入GPIO BSRR中的某些位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42590083/