UART overrun flag may set when executing IRQ handler

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

UART overrun flag may set when executing IRQ handler

跳至解决方案
970 次查看
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;
}

 

 

 

 

标签 (1)
0 项奖励
回复
1 解答
940 次查看
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 项奖励
回复
3 回复数
951 次查看
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 项奖励
回复
946 次查看
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 项奖励
回复
941 次查看
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 项奖励
回复