cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H753: Can't receive the data the controller is sending

jhi
Senior

I'm using the UART (USART5) with RS485 and I have enabled the read to be on also when sending. I need to read back the data that was sent to see if it is correct. The problem is, that I do not receive what was sent. But if I send the same data from other device (without changing any code), I will receive the data. So the receive works, but not the same time with sending.

Initialization - FIFO is also enabled.

 

BaudRate = PARALLEL_BAUD_RATE;
DataWidth = LL_USART_DATAWIDTH_8B;
Parity = LL_USART_PARITY_NONE;
StopBits = LL_USART_STOPBITS_1;
HardwareFlowControl = LL_USART_HWCONTROL_NONE;
OverSampling = LL_USART_OVERSAMPLING_16;
PrescalerValue = LL_USART_PRESCALER_DIV1;
TransferDirection = LL_USART_DIRECTION_TX_RX;

 

And data sending is done with LL_USART_TransmitData8. The half-duplex is not enabled.

What could block the receive when sending?

38 REPLIES 38

@CharlieMangold In your schematic, you only have a single signal, so TX and RX can't be active at the same time. This is like using UART in one-line mode where a single pin is used for both TX and RX.

Full-duplex 485 transceivers can have both directions active at the same time and has two signals, one for TX and a separate one for RX.

If you feel a post has answered your question, please click "Accept as Solution".

Seemed like it could, but because the signal is twisted pair it would require twice as many lines and I did not think @jhi had been specific about that.

Thanks.

Why would the data be lost? You would receive what you send. This is what I‘m doing or actually trying to do. The sent data is seen on RX but the MCU doesn’t seem to get it. And that is the reason for this discussion.

What seems to be missing is your exact setup to fully understand the issue. Are you running a single signal 485? If so the 485 chip(like the one we have) is not going to pay attention to the transmitted data(i.e. the data will be lost.) Your word description implies that there is data coming into the Rx line(via a loopback?) which makes me think you  have at least two 485 twisted pairs(two signals.) I'm not a 485 expert but a single 485 signal uses two lines twisted together where each line has the signal inverted from the other line for better noise immunity. How could you send a packet out and get it back because you can't do this with a single 485 signal(take BACnet MS/TP or ModBus for example.) It's hard for me to tell how you have things connected so I'm not much help.

Because the signal on bus doesn’t have any direction, the receiver in RS485 will send it of course back if RE is enabled. It doesn’t matter who is sending the data. That is why you normally disable the receiver when you send your data so that you won’t receive the sent data. Now I want to read it back to know that my RS485 receiver is working and that there was no collision with other device sending at the same time. The HW I have is like yours. And as I have many times already written, I can see the data on RX line with logic analyzer so HW is working as it should. Only the MCU doesn’t want to see it.

Pavel A.
Evangelist III

@jhi Yes as you describe it, MCU must receive. The UART is in normal full duplex mode and receives from something else . You see the signal on the entry. But something still is wrong. Is the signal level good? Isn't it inverted?

jhi
Senior

The signal is correct. The HW works because I can send data from other device and I can receive that. 

TDK
Guru

Ultimately, the STM32 doesn't know where the signal is coming from. If it can receive data from other chips, it will also receive data it transmits, provided that signal is what's on the bus. Has to be something different about your setup here, and you're the only one with access to the hardware.

One of these is wrong (or it would be working), so recheck assumptions, figure out which one it is: 

  • Signal on bus is correct.
  • Receiver translates bus correctly and delivers it to RX pin.
  • STM32 is programmed correctly to receive signal on RX pin.

Look at or print out UART registers to convince us and yourself that it's programmed correctly. Look at UART error flags.

Have to believe that between this and your other thread, there's a fundamental issue.

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

Have you tried to send from the other source simultaneously while STM32 transmits? (disconnecting the RX from your RS485). Will STM32 receive?

 

Looking at the simplified schematic of our chip I would not have guessed that the transmitted data would make it back to the receive line. I get that you keep saying that you see data being received but honestly I thought maybe you were mistaken as you showed no O-scope traces(it's hard to tell experience levels here.)

Capture.JPG

 

If the data is making it there then it must be a configuration issue. You could try turning off the FIFO's to simplify things and as @TDK mentioned examine all the USART config registers to insure there is not some bit set incorrectly. If you have debug capability configure the USART Rx interrupt to fire and set a break point there.

LL_USART_EnableIT_RXNE_RXFNE(USART1);
NVIC_SetPriority(USART1_IRQn, 1);
NVIC_EnableIRQ(USART1_IRQn);
LL_USART_DisableFIFO(USART1);