cancel
Showing results for 
Search instead for 
Did you mean: 

Bare metal programming issue

ALMAAROUF
Associate II

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

ALMAAROUF_0-1723744937707.pngALMAAROUF_1-1723745002780.pngALMAAROUF_2-1723745080558.pngALMAAROUF_3-1723745127137.pngALMAAROUF_4-1723745179971.png

 

 

2 REPLIES 2
ALMAAROUF
Associate II

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);
}

 

TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".