cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L152 USART3

costi
Associate III

I tried to use USART3. After few RX/TX messages the port is locked. It stay always into interrupt routine. Only the RX/TX interrupts are handled (activated). Ther is somebody with the similar situation? Thanks.

5 REPLIES 5

One common pitfall is when the ISR does not handle the overrun flag.

JW

costi
Associate III

Agree, but I can't leave the ISR routine in this situation, only using the the watchdog or reset by power supply. What can I do? Normally over run flag is erase reading the status register and after that data register but is not happen.

Any idea ?

costi
Associate III

And another thing. This strange behavior is happened only at the speed over 19200 baud.

There is a reason why the ISR is not exited, look at all the flags - read out the status register (or better all USART registers) at the moment when problem is present, and post them.

JW

costi
Associate III

I solved my problem.

First time I just compared the ORE flag and after that I read data register when the interrupt flag RXNE was set.

if(USART3->SR & USART_SR_ORE){}

after that I read data uyDataRead = USART3->DR;

In this situation when the ORE bit is set the program remained always in the interrupt routine.

I solved the problem using the example below after that interrupt is activated:

STATUS_REGISTER = USART3->SR;

DATA_REGISTER = USART3->DR;

The variables STATUS_REGISTER and DATA_REGISTER are used in the interrupt routine.

This is the condition to reset the ORE flag. But if the ORE flag is set that means that is possible to loose at least one byte from the received frame.

This happened because of interrupt priorities.

I set the USART3 interrupt as higher priority and the reception is OK now even at the higher speed.