Skip to main content
TPand
Associate
September 6, 2019
Question

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

  • September 6, 2019
  • 3 replies
  • 1293 views

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

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
September 6, 2019

This looks OK.

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

JW

TPand
TPandAuthor
Associate
September 7, 2019

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

waclawek.jan
Super User
September 8, 2019

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