cancel
Showing results for 
Search instead for 
Did you mean: 

UART intrrupt

vitthal muddapur
Associate II
Posted on April 11, 2018 at 08:24

Hi,

New in STM32. I have Enabled only UART Receiver interrupt it's working fine 

but some time continuously execute ISR without incoming data and Disable OVERRUN. 

Thanks and Regards 

vitthal

9 REPLIES 9
Posted on April 11, 2018 at 08:35

Check for other ISR bits or error status being flagged.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 11, 2018 at 08:40

I have Disable All Error flags intrrupt

Posted on April 11, 2018 at 08:48

Check the error flags INSIDE the interrupt handler.

And NEVER spend more time in the handler than the transmission of a byte takes.

Posted on April 11, 2018 at 08:55

Hi,

if(LPUART1->ISR & 1<<0){

LPUART1->ICR|=(1<<0);        Parity error clear

}

if(LPUART1->ISR & 1<<1){

LPUART1->ICR|=(1<<1);       Framing error clear

}

if(LPUART1->ISR & 1<<3){

LPUART1->ICR|=(1<<3);       Noise detected clear

}

if(LPUART1->ISR & 1<<2){

LPUART1->ICR|=(1<<2);     Overrun error clear

}

this Right or not

Posted on April 11, 2018 at 10:32

if(

LPUART1

->ISR & 1<<0){ ...

Looks like you are using a L4xx device, which I never worked with.

For projects with L051, F30x and F40x devices, I used to clear errors in a similar way, directly in the status register.

The register name differs between device families, so check the Reference Manual for your part.

And, as said: don't spend long times in interrupt routines.

Calling printf() in an interrupt handler is a perfect example.

Also, there is a known race condition in Cortex M devices.

Don't clear interrupt flags as the very last action in the handler, this might cause a re-entry as well.

Posted on April 11, 2018 at 10:55

this STM32l071

Posted on April 11, 2018 at 12:39

Not sure what distinguishes a LPUART from a normal UART - check with the RM.

... but some time continuously execute ISR without incoming data and Disable OVERRUN.

Indicates either an unhandled error condition (noise or corruption on the line) or overrun (your handler takes too long).

Your idea of clearing the error flag might work, but check with a debugger for the actual cause.

A bugfix assumes you identified and confirmed the issue properly.

Posted on April 11, 2018 at 12:48

I have not Enabled any ERROR INTERRUPT

Posted on April 11, 2018 at 13:41

Ok, and what statuses to you see on this repeated calling? Hard to see from here. What do the registers indicate, what code paths within your code are active?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..