I'd like to use the UART+DMA to talk to a coriolis sensor via modbus.
All things are work okay, but sometimes after 1-3 minutes I lost one byte of the answer.
Every 100ms a measurement value is querried from the sensor. The answer of the senser should be 37 bytes long.
With the help of an RS485-USB adapter I control the response of the sensor. There you can always see all 37 characters. In the input buffer (MB_inbuffer), which is filled by UART via DMA, there are sometimes only 36 characters!
Additionally the data stream was analyzed by an oscilloscope and no (big) deviations were detected. The sensor transmits with 38661 baud (according osci) and the measured (checked on HSO_0 pin) clk frequency of the UART divded by 8 result in 38460baud. So there is a 0.5% deviation between this two frequencys, which should be okay.
Therefore I cannot explain the missing byte.
Mostly a 00 byte is missing if several are sent in series. (but not always)
01 03 20 47 7D 3C 8A 00 00 00 00 74 BF 41 C8 00 00 00 00 00 00 7F A0 00 00 7F A0 00 00 00 00 00 00 00 00 9A 6B
01 03 20 47 7D 3C 8A 00 00 00 00 74 BF 41 C8 00 00 00 00 00 00 7F A0 00 00 7F A0 00 00 00 00 00 00 00 9A 6B
In this case on the oscilloskop there is no deviation in the byte length of this 8 '00'-bytes. All 8 bytes are identical. So I have no clue why in the input buffer one is missing...
the dma is initialized with the following code:
For each query following code is used:
char send_modbus(T_MODBUS *p)
RS485_OUT; //macro to set sending pin on RS485 transceiver
CyDmaTdSetConfiguration(dma_Coriolis_RX_ChannelHandle_TD, p->count_rec, CY_DMA_DISABLE_TD, dma_Coriolis_RX__TD_TERMOUT_EN | TD_INC_DST_ADR );
CyDmaTdSetConfiguration(dma_Coriolis_TX_ChannelHandle_TD, p->count_send, CY_DMA_DISABLE_TD, dma_Coriolis_TX__TD_TERMOUT_EN | TD_INC_SRC_ADR );
CyDmaTdSetAddress(dma_Coriolis_TX_ChannelHandle_TD, LO16((uint32_t)&(*p->message)), LO16((uint32)UART_Coriolis_TXDATA_PTR));
*p is a pointer to the send/receive structure.
p-> count_rec is 37 for a normal measurement query.
Is there something wrong with the DMA configuration?