我最近买了一个STM-NUCLEO,我正试着写信给PA0,PA1,PA2,PA3,它们都连接到LED上。LED和PA0,PA1按预期亮起,但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控制器,因此如果不先添加和删除一些网桥,就不能用于GPIO。
这是你的MCU,“SB62,SB63默认打开”意味着连接不存在。
这就是它连接到ST-Link接口的地方。