Skip to main content
Indois
Associate III
May 14, 2021 12:22 AM UTC
Question

Receiving/transmitting using UART and LL API

0693W00000AOIHrQAP.pngHello,

I am experiencing some problems when trying to receive data from PC using UART and then check if it is correct. I am using using LL API and this code is placed in while(1) of main function. For example, when I send 'A' from PC to STM32, PC receives response with '0x01' but if I try to send 'A' again, it does not respond anymore. Do I have to clear some flags of USART before receiving again?

Thank you

This topic has been closed for replies.

7 replies

Tesla DeLorean
Guru
May 14, 2021 1:14 AM UTC

Need to wait of TXE for the transmit, and RXNE on the receive

LL_USART_IsActiveFlag_TXE(USART2)

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Indois
IndoisAuthor
Associate III
May 15, 2021 11:29 AM UTC

I noticed that LL_USART_TransmitData8 function successfully transmits chosen value every time when data = 'A' is received:

0693W00000AOTW9QAP.png 

But now I want to transmit a string:

0693W00000AOTXqQAP.png 

TransmitString function:

0693W00000AOTYUQA5.png 

And the problem is that string is transmtited only one time when first time data = 'A' is received. When data = 'A' is received again, nothing is transmitted. Could you help me to solve this problem?

Indois
IndoisAuthor
Associate III
May 16, 2021 1:22 AM UTC

I found out that when I transmit only one symbol, for example '9' or 'C' then data recption is not blocked. But if I transmit more than one symbol, for example '10' or 'CC', then data reception is blocked. Could you help me to solve this problem?

Indois
IndoisAuthor
Associate III
May 17, 2021 8:48 PM UTC

The problem is that when more than one symbol (digit or letter) is sent from PC to STM32 over UART , then STM32 received value (in my case called data) becomes '13' and it does not change anymore no matter how many times I send any values from PC to STM32 again.

waclawek.jan
Super User
May 18, 2021 5:24 AM UTC

Which STM32?

Maybe receiver stops working due to unhandled overrun error?

JW

Indois
IndoisAuthor
Associate III
May 18, 2021 1:12 PM UTC

I use STM32L011. I will try to check if this code of overrun error correction helps. Thank you.

Indois
IndoisAuthor
Associate III
May 19, 2021 12:30 AM UTC

How should I use this function?

0693W00000AOr7SQAT.png 

It blocks receiving data if I start it in while, before data=LL_USART_ReceiveData8(USART2).