2024-08-15 11:08 AM
I am a beginner in embedded programming and I have a problem programming the nucleo board. I want to turn on the LED built into the board and connected to the PA5 in a bare metal way, but I could not turn it on even though I followed the steps that I found on the Internet. I hope you can help me figure out what's wrong
the board that i am using is stm32l053R8 nucleo
2024-08-15 11:13 AM
the code that i tried and didnt work is
#include <stdint.h>
#define RCC_IO_PORT_EN_R (*(volatile uint32_t*)0x0000002CUL)
#define GPIO_A_MODE_R (*(volatile uint32_t*)0x50000000UL)
#define GPIO_A_OD_R (*(volatile uint32_t*)0x50000014UL)
int main()
{
RCC_IO_PORT_EN_R &=~ (1UL);
GPIO_A_MODE_R &=~ (1UL<<10);
GPIO_A_MODE_R &=~ (0UL<<11);
GPIO_A_OD_R &=~ (1UL<<5);
}
2024-08-15 12:29 PM - edited 2024-08-15 12:30 PM
To set bits, you should use the |= operator. The "&=" operator can only clear bits.
Using the standard CMSIS defines will be more productive and will make your program easier to read. For example:
RCC->IOPENR |= RCC_IOPENR_IOPAEN;
These can be found in the "stm32l053.h" file.