2020-06-30 01:41 PM
I have Nucleo-G071RB. I want to flash the LED LD4 using CMSIS. Use IAR 8.40
I'm writing the following code: GPIOA->MODER |= 0x400; (set GPIO_MODER_MODE5_0). It's not working! In the debugging window, bit 11 doesn't change and the LD4 LED doesn't switch!
However, if I write a GPIOA->MODER = 0x400; then it works. (the debugger doesn't work because it's on GPIOA the same way, but it doesn't matter).
The same thing is happening at other ports B, C, ...
What's my mistake?
Thank you.
2020-06-30 03:09 PM
The reset value of GPIOA->MODER is 0xEBFF FFFF; so both bits of MODE5 are already set, by ORing to them they can't change.
GPIOA->MODER = (GPIOA->MODER & ~GPIO_MODER_MODE5) | (1 * GPIO_MODER_MODE5_0);
JW
2020-06-30 03:56 PM
My error was that I didn't look at the set default values in MODER registers (F0 series - ...00000000000, G0 series - ...11111111).
Thanks!
2024-01-22 03:56 PM
Try this one:
1- First set the address of the GPIO->MODER Register
GPIO_MODER = (uint32_t*)0x48000000;
2- Set the MODER [9:8] = 0x1
*GPIO_MODER |= 0x400;