I have generated a code from STMCUBEMX for UART using DMA for Tx and Rx. The DMA is used so that the main function should not be disturbed.
I did not call these below functions in the while loop.
These receiving function is triggered once the start bit is find. The communication is proper but if I disconnect and connect the Rx line, no data is received. If I reset the program then the data is received and the same problem occurs.
If I called the receiving function in while loop then it is working fine which delays the main operations. So I wanted it to run in background.
This is just a snippet. We don't see periferal configuration, nor variabkes declaration.
Nor do we see how you transmit any data.
****
How the DMA receive works:
Let's say you declare data_rx array to be 4 char in size.
* Then you call the non blocking receive_DMA function. The function returns immediately. Other code gets processed.
* 1st byte arrives and gets stored by DMA without using processing power. No ISR is called.
* 2nd byte arrives and gets stored by DMA without using processing power. No ISR is called.
* 3rd byte arrives and gets stored by DMA without using processing power. No ISR is called.
* 4th byte arrives and gets stored by DMA without using processing power.
* now the DMA buffer is full, thus the receive_complete ISR gets called
We don't see what happens when the first byte is 0x3A or not.
One problem may be that during connection one erroneous byte is received.
So the 0x3A gets stored at position 1 (instead of position 0). = mis aligned
I see nothing in your code that corrects for mis-alignment.
I guess you expect that the receive_complete gets called for every single byte. But this is not true for DMA operation. Indeed that's the benefit of DMA operation.