cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_UART_Receive_IT() - problem with correct receiving

Dawid Kozub
Associate II
Posted on July 03, 2017 at 16:49

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

0690X00000607NQQAY.png

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

I did measurement by osciloscope:

0690X00000607MrQAI.png

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..

     Dawid

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on July 03, 2017 at 17:57

Any potential for it to be in other interrupts of higher priority?

Can you have the transmitter of the data use 2 stop bits?

Are you viewing the USART internal state in a debugger?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2
Posted on July 03, 2017 at 17:57

Any potential for it to be in other interrupts of higher priority?

Can you have the transmitter of the data use 2 stop bits?

Are you viewing the USART internal state in a debugger?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Dawid Kozub
Associate II
Posted on July 04, 2017 at 10:53

Problem was with interrupts priority of course. I had no configured IRQ's priorities. 

THANK YOU Clive One for fast answer and of course  huge HELP

PROBLEM SOLVED. TOPIC CLOSED FOR ME.