2019-10-15 07:28 AM
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.
2019-10-15 07:45 AM
One common pitfall is when the ISR does not handle the overrun flag.
JW
2019-10-15 09:08 AM
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 ?
2019-10-15 09:09 AM
And another thing. This strange behavior is happened only at the speed over 19200 baud.
2019-10-15 10:14 AM
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
2019-10-16 09:52 AM
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.