UART overrun flag may set when executing IRQ handler

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART overrun flag may set when executing IRQ handler

Jump to solution
613 Views
jake111
Contributor I

There is some posibility that UART get an overrun flag due to big data flows in my project.Sometimes an RX interrupt is executing,I have also checked overrun flag in the s_uart_Isr(UART0, s_uartHandle[0]) and overrun flag isn't set.But at the end of the IRQ handler,the overrun flag is set.So no another interrupt will be generated.I have to add two lines of code as below,how can I avoid this?Enable the interrupt nesting?(I'm using FreeRTOS)

 

 

 

void UART0_DriverIQRHanlder(void)
{
    s_uart_Isr(UART0, s_uartHandle[0]);
    /* I have to add two lines as below to clear overrun */
    if(UART_GetStatusFlags(UART0) & kUART_RxOverrunFlag)
        UART_ClearStatusFlags(UART0, kUART_RxOverrunFlag);
    SDK_ISR_EXIT_BARRIER;
}

 

 

 

 

Labels (1)
0 Kudos
1 Solution
583 Views
bobpaddock
Senior Contributor III

"I wonder why the interrupt nesting should be disabled?"

As the levels get deeper it becomes harder to reason where the race conditions will appear.

This also generally indicates that the system is overloaded if it becomes necessary.

If there is no other choice do nothing other than increment a value, never set a flag because clearing it becomes a race condition, or deal with the hardware event that must be dealt with to meet the timing constraints of the system design.

The the variable that gets incremented is compared to a past value at a higher level where things can be dealt with.


 
 

View solution in original post

0 Kudos
3 Replies
594 Views
bobpaddock
Senior Contributor III

"Enable the interrupt nesting?"

The answer to that question is almost always an emphatic 'No'.

If the ISR takes longer to run than the rate the data is coming in at would certainly cause this.
We really can't say more, without seeing more of the code.


0 Kudos
589 Views
jake111
Contributor I

Thanks,I have deleted some time-consuming code in the irq handler.

 

I wonder why the interrupt nesting should be disabled?

0 Kudos
584 Views
bobpaddock
Senior Contributor III

"I wonder why the interrupt nesting should be disabled?"

As the levels get deeper it becomes harder to reason where the race conditions will appear.

This also generally indicates that the system is overloaded if it becomes necessary.

If there is no other choice do nothing other than increment a value, never set a flag because clearing it becomes a race condition, or deal with the hardware event that must be dealt with to meet the timing constraints of the system design.

The the variable that gets incremented is compared to a past value at a higher level where things can be dealt with.


 
 
0 Kudos