Ich kaufte vor kurzem eine STM-NUCLEO und ich versuche, PA0, PA1, PA2, PA3 zu schreiben, die an LED's angeschlossen sind. Die an PA0 und PA1 angeschlossenen LEDs leuchten wie erwartet, aber PA2 und PA3 nicht. Ich habe es mit PA4 versucht und das funktioniert auch. Hier ist der Code:STM32 NUCLEO F401RE kann nicht schreiben in einige Bits in GPIO BSRR
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)
{
}
}
Das macht Sinn, danke. – Jonathan