Skip to main content
Haddock
Associate III
December 20, 2022
Solved

USART frame detect IRQ. How?

I'm modifying code for a Atmega AVR to a STM32L03 and encounter ISR(USART1_START_vect). It is a function that is called when the UART receives a start frame. I'm a newbie to this STM32-processor but I have googled and checked in inc-files but I cannot find any suitable code. I'm using HAL for now.

Have anyone a suggestion?

Thanx

This topic has been closed for replies.
Amel NASRI
Amel NASRIBest answer
ST Technical Moderator
December 28, 2022

Hi @Håkan Nalén​ ,

If you need a simple EXTI example, you can refer to this wiki article: Getting started with EXTI.

Several ready to use examples are also available in the STM32CubeL0 package. You can refer to some of them here.

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.

14 replies

Tesla DeLorean
Guru
December 20, 2022

What does your code do with such an interrupt?

If you want to detect the pin is active, perhaps use an EXTI interrupt​.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Haddock
HaddockAuthor
Associate III
December 20, 2022

I have two UART ports. Both can occupy an interpreter and each port sets a flag that says "I now own the interpreter". That flag is set in this ISR().

I suppose a Frame detect IRQ coming when the hardware pin change state.

I must read about the EXTI interrupt..

waclawek.jan
Super User
December 20, 2022

> when the UART receives a start frame

Define "start frame".

> I have googled and checked in inc-files

Read the Reference Manual (RM) to your STM32.

JW

Haddock
HaddockAuthor
Associate III
December 20, 2022

I suppose a Frame detect IRQ coming when the hardware pin change state in the beginning of the transfer.

waclawek.jan
Super User
December 20, 2022

If it's this

0693W00000WLQbcQAH.pngthen as Clive said above, EXTI may be a direct equivalent. However, for the purpose you've described, IMO it's better to "flip the switch" upon reception of the first byte on given UART.

JW

Haddock
HaddockAuthor
Associate III
December 20, 2022

The note from 328PB is exactly what I want to happen in STM32-mcu.

The EXTI line 26 o 28 is activated in project.ioc file. I found the file stm320xx_hal_exti.c and what I can see this is the file that deals with EXTI.

Because I'm a newbie regarding this processor I searching for the interrupt function. Is it HAL_EXTI_IRQHandler() ?

If U have another Tips & Trix/manual for the processor and how to make a sw design in this target I would appreciate a tip. I found Target Device Docs and Resources in the Help menu i the IDE...

Thanx

Amel NASRI
Amel NASRIBest answer
ST Technical Moderator
December 28, 2022

Hi @Håkan Nalén​ ,

If you need a simple EXTI example, you can refer to this wiki article: Getting started with EXTI.

Several ready to use examples are also available in the STM32CubeL0 package. You can refer to some of them here.

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
Piranha
Principal III
December 20, 2022

> I have two UART ports. Both can occupy an interpreter and each port sets a flag that says "I now own the interpreter". That flag is set in this ISR().

And why cannot it be done when the data is received?

Haddock
HaddockAuthor
Associate III
January 3, 2023

The interpreter library is written to handle only one UART port. The code includes detection of start and stop frames. If I do this detection outside the library functions, the impact will be too great. It is easier to hire the interpreter after the first byte has arrived and continue to feed the interpreter with more data until the entire message is processed. After that the flag is reset and the respective UART buffer is checked if more data has arrived.

Haddock
HaddockAuthor
Associate III
December 21, 2022

You are probably right. I can set the flag after the first byte has been received. The uart-ports has their own buffer but there is only one input buffer for the interpreter. I can set the flag in Rx-complete IRQ for the specific port.

Thanx. It is a simple solution and I get less IRQ:s.