cancel
Showing results for 
Search instead for 
Did you mean: 

Weird LPUART interrupt behaviour

XKeto.1
Associate

Hi,

i write code in bare metal so every time i initialize a project in STM32CubeIDE i do it as an empty project. I made a project for STM32L011K4 and try to initialize the LPUART, in the startup file i can find that the handler for the LPUART1 name is AES_RNG_LPUART1_IRQHandler. I try to write my code for this handler but when i debug the code hang in loopforever at the default handler. Next step i proceed it was to make the same project as STM32Cube and not as empty. The startup file there was different the handler's name is LPUART1_IRQHandler, i copy and paste the code from the startup file of STM32Cube in my empty project, write code for LPUART1_IRQHandler and it worked. So did i miss something or it is a bug?

OS: Arch Linux

IDE: STM32CubeIDE 1.7.0

Steps to reproduce:

  1. Create empty project for STM32L011K4
  2. Create STM32Cube project for STM32L011K4
  3. Startup files (In Startup folder) are different
3 REPLIES 3
TDK
Guru

In order for the appropriate IRQ handler to be called, the function name in your code needs to match the function name given in the vector table (typically in startup_*.s). It doesn't really matter what they're called.

They should probably be the same name here for consistency, but it's weird how creating an "empty project" creates code at all.

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

Yes i know that and i name my function AES_RNG_LPUART1_IRQHandler because that was the only handler that has LPUART at its name, i enable the AES_RNG_LPUART1_IRQ interrupt and when i run it it just go to default handler, which it mean that an interrupt has occur (LPUART) that cannot find its handler. After creating an CubeIDE project i just copy the code from the startup file(which is older) and change the name to LPUART1_IRQHandler and LPUART1_IRQ respectively and everything run fine. To me it seems like a bug.

Reproduce:

  1. Make an empty project for STM32L0x1
  2. Make an STM32Cube project for STM32L0x1
  3. Compare startup files

VBobr.1
Associate

Hello.

I have the same situation. The RXNEIE interrupt for LPUART did not work until I replaced the startup_stm32l031f6px.s file with the same one from the STM32Cube project.

Thanks to @XKeto.1 for this workaround.

MCU: STM32L031F6.

IDE: STM32CubeIDE 1.8.0

LPUART_init.c

...

// Enable transmitter, receiver and receive-interrupt of LPUART1

LPUART1->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_RXNEIE | USART_CR1_UE;

...

0693W00000JPb4fQAD.jpg