Skip to main content
ControlFreak
Associate III
October 19, 2018
Solved

STM32L4+ USART RX+Interrupt Not working

  • October 19, 2018
  • 15 replies
  • 4778 views

Hello,

I am trying to configure USART1 on Nucleo-32 board using HAL. Code is suppose to first it receive the message and then it transmits the same message.

My problem is RDR is showing reading garbage value. Can someone point out was is wrong?

(Please ignore my indentation of code- this is just my test run)

This topic has been closed for replies.
Best answer by Bob S

You say "RDR is showing reading garbage". But you are not accessing RDR directly. Do you mean your rx buffer shows something other that what you expect? If so, what were you expecting to receive and what did you actually receive? When you first transmit your canned "aTxBuffer", does whoever receives that get THAT data OK? Can you loop-back your TX to your RX (perhaps on the far side of the LTC2873) and see if you can receive the same thing that you send.

I don't see you supplying an error callback function. Do you know if any of the error bits are getting set?

You configure the LTC control lines then immediately start sending. Does the LTC part need any specific delay between changing control lines and actually being able to rx/tx data?

Are you currently looping back the serial port, such that you are expecting to receive the same 5 bytes that you first sent before the while() loop? If so, the 1 second delay after the HAL_UART_Transmit_IT() call will cause you to miss that data.

FYI - it is perhaps better forums etiquette to actually include your source in your post as opposed to requiring us to download it. As your user name implies, I am also a control freak and very hesitant/paranoid about downloading files of unknown content, even from forums that I hope and presume would filter files before allowing them to be posted :)

15 replies

T J
Senior III
October 19, 2018

this code is blocking code,

I hope you clear that flag in the loop now...

It wont work without it.

Can you stop the processor and look in the tables ?

T J
Senior III
October 19, 2018

this code is blocking code,

I hope you clear that flag in the loop now...

It wont work without it.

Can you stop the processor and look in the tables ?

ControlFreak
Associate III
October 19, 2018

if you mean by clearing rx_cplt flag, printscreen is after I have cleared flag in main loop. As I have mentioned it earlier, that even if I debug my code my RDR show 0c0,0xf8 etc.

T J
Senior III
October 19, 2018

the RDR only has 16bits, and only 8 bits of that is used for Char transfers. ( 1 byte only)

don't look at the RDR you must look in the receiving buffer.

otherwise, try to use the DMA functionality, it works very well.

ControlFreak
Associate III
October 24, 2018

Sorry for late updates. I have solved this issue. There was couple of problems

1) connection between Trans receiver and Computer were wrong

2) the was more then 3% error in my baud rate

4) as pointed by BobS, timing issue

Special thanks to Bob S and T J for prompt reply.