c - STM32 NUCLEO F401RE无法写入GPIO BSRR中的某些位

标签 c arm embedded stm32

我最近买了一个 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”表示连接不存在。

enter image description here

这是它连接到 ST-Link 接口(interface)的地方。

enter image description here

关于c - STM32 NUCLEO F401RE无法写入GPIO BSRR中的某些位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42590083/

相关文章:

c - 尺寸过大时 VBO + glBufferData 崩溃

c - FreeRTOS 应用程序堆栈可用内存随着时间的推移而减少

c++ - 是否可以在 ARM Windows 主机上本地编译 ARM Windows C++ 软件?

arm - Thumb-2指令的W后缀是什么意思?

java - 如何在 Samsung Galaxy Tab 上停止通话音频并保持通话?

error-handling - HardFault cortex,我该如何调试它

c - 如何单独从数组中取出每个单词并测试它是否符合特定条件? (C)

c - C 中的阶乘递归(段错误)

openssl - 针对Linux arm-v5te-linux-gnueabi工具链的openssl的交叉编译

c - switch 语句终止后不会重新启动