AnsweredAssumed Answered

HAL_UART_Receive_IT() - problem with correct receiving

Question asked by Dawid Kozub on Jul 3, 2017
Latest reply on Jul 4, 2017 by Dawid Kozub

Hello again community !


I have next problem with my stm32F030RCT6. Problem is with receiving data from UART. In my project I am using all 6 UART’s that is why I can’t use DMA for all UART’s (this Mcu has no enough DMA channels). Problem is with about 30 % received frames by HAL_UART_Receive_IT() . With DMA receiving has no problem. While receiving bytes sometimes occurs faults. I am receiving one byte by one. For example USART settings:

Baud Rate: 115200
Word Length: 8 Bits
Parity: None

Stop Bits: 1

Data Direction: Receive and Transmit

Over Sampling: 16 Samples
Single Sample: Disable

Polarity: High

Assertion Time: 0 Sample Time Unit

Deassertion Time: 0 Sample Time Unit


Overrun: Enable

DMA on RX Error: Enable

MSB First: Disable

------------------------------ CLOCK -----------------------------

RCC: HSE - Crystal/Ceramic Resonator

          LSE - Disable



When Baud Rate is set to 9600 everything is ok, there are no faults.

I did measurement by osciloscope:




Chanel 2: time spend in HAL_UART_Receive_IT() <-- one byte processing

Chanel 3: time when  fault occurs (time spend in HAL_UART_ErrorCallback)

Chanel 4: UART RX pin


On screenshot You can see:

1. first byte of my frame 0x55 <-- this byte is processed correct - first peak on chanel 2

2. second byte of my frame 0x10 <-- with this byte is problem, because after it has no interrupt

3. third byte of my frame 0x02 <-- after this byte interrupt occurs, but in this time occurs also fault - second peak on chanel 2 and first peak on chanel 3

4. fourth byte of my frame 0x01 <-- after this byte and all other there are no faults, but all received frame is incorrect.


In received buffer are bytes: 0x55, 0x02, 0x01, 0x76, 0x00.... (there is no second byte --> 0x10) This time was problem with second byte, it is random...


While I am sending 100 that frames, faults have about 30% (70% are correct). 

HAL_UART_GetError(); returns  Overrun error, but not all time when fault occurs. When overrun error will appear USART 1 does not work any longer...


I did this measurement, because i want to know how long I am in HAL_UART_Receive_IT() and when faults occurs...

Where is the problem ? What can I check ? What should I do ?

Please help..