Turning ON LED on Nucle-G474RE not working when not using HAL
Hi.
I am learning how to turn on LED2 of a NUCLEO-G474RE board by using registers (without HAL).
I have created a small project which contains:
// This first block works and updates the registers
// Start GPIOA Clock
(*(uint32_t*)0x4002104C) &= ~(1 << 0); /* AHB2ENR clear */
(*(uint32_t*)0x4002104C) |= (1 << 0); /* AHB2ENR set */
(*(uint32_t*)0x4002102C) &= ~(1 << 0); /* AHB2STR clear */
(*(uint32_t*)0x4002102C) |= (1 << 0); /* AHB2STR set */
// This block doesn't work
// Set mode 10 for GPIOA PIN 5
(*(uint32_t*)0x48000000) &= ~(0x3 << 5 * 2); /* GPIOA MODER clear */
(*(uint32_t*)0x48000000) |= (0x2 << 5 * 2); /* GPIOA MODER set */
// This block doesn't work
// Set GPIOA PIN 5 as HIGH/SET state
(*(uint32_t*)0x48000014) &= ~(1 << 5); /* GPIOA ODR clear */
(*(uint32_t*)0x48000014) |= (1 << 5); /* GPIOA ODR set */
The RCC register to enable clock for AHB2ENR seems to work. I can see the register change. But MODER and ODR registers doesn't seem to change. Could somebody tell me what I am doing wrong?
When I connect to the board with STM32CubeProg I can access the registers and change also AHB2ENR register but not MODER and ODR.
Thanks in advance.
Raúl Pérez
