cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring STM32 PA5 port for output (using Nucleo-L073RZ board)

TPand
Associate

Hi,

I am using KEIL to program PA5 pin which is connected to the user LED. But after writing the program, I am unable to get the LED on. It is a simple program but I am not sure, why it is not working. Any help will be appreciated.

#include "stm32l0xx.h"                  // Device header
 
int main (void)
{
	
	RCC->IOPENR |=  0x1;
	GPIOA->MODER |= (1<<10);
	
	while(1)
{
		GPIOA->ODR = 0x20;	
	}	
}
 

Regards,

Tapas

3 REPLIES 3

This looks OK.

You can in Keil single-step the program, and/or check the registers content.

JW

TPand
Associate

Hi,

I am able to turn ON Led in F407 discovery board.

But why it is not working in L053/73 board.

I have spent three hours reading reference manual but unable to get the answer.

Code that is working in F407 discovery board

#include "stm32f4xx.h"                  // Device header
 
int main(void)
{
	RCC->AHB1ENR |= 0x8;
	GPIOD->MODER |= 0x1000000;
	
	while(1)
	{
		GPIOD->ODR = 0x1000;
	}
}

Regards,

Tapas

As I told you, look at the register's in the debugger.

You would then probably spot that MODER content is not what you intended, as in 'L0 its reset default content is not 0x00000000 as in the 'F4.

JW