2019-04-16 04:20 AM
we are trying to read the line voltage register in the energy meter(em6400ng) using mod bus RTU over RS-485 protocol. we are assembling the packet in an array and sending it to the energy meter using DMA. also we are receiving the packet in a buffer using interrupt. The energy meter is only sending the first byte that is slave id in response. we are not able to find out the reason this occurrence, please point out the problem in our code. The code is attached below.
2019-04-18 02:06 AM
yes,I checked with the mod bus master software and the meter is responding properly.
2019-04-18 02:12 AM
I checked and the MCU has a RTS/CTS interface should I use it. Also it has a special bit for half duplex transmission,I did not use it should I use it in this case.
2019-04-18 03:59 AM
I don't know your interface line handling, it seems not in the code you posted.
Check that the transfer direction is managed correctly, especially during reception.
Don't spend too much time in the receive interrupt. If you get an overflow, reception stops until you reset the flag manually.
Check for other UART errors in the interrupt handler.
My suggestion - clear the error flags, possibly marking the current response frame as invalid.
Receive the remaining bytes, and then drop it.
Repeat the request frame.
2019-04-18 04:18 AM
yes, because,my meter has only Tx/Rx lines it does not have a RTS/CTS flow control to connect to.
2019-04-18 04:46 AM
Ok I will try to use RTS to control the enable pins,and try clearing overrun flag which was getting set
2019-04-19 02:18 AM
After clearing the overrun flag also it is only reading 1 byte. I was enabling the Receive enable inside the ISR , that was causing the overrun error. If I enable Receive pin inside main the error is solved but the receive buffer is reading the same packet which was transmitted.
2019-04-19 02:46 AM
This seems to depend on your hardware. If the Tx signal is feedback, you could safely ignore it (i.e. drop all received characters while you are sending).
I know that layout/hardware changes are usually difficult to press through, so you will probably settle with a SW workaround.
Not sure what the initial post means about DMA, but receive timing control (required for RTU) and DMA seems not the best choice to me.
2019-04-19 02:52 AM
should I transmit also through interrupt,instead of DMA.