AnsweredAssumed Answered

UART_DMA Delay ?

Question asked by einstein.john on Oct 26, 2015
Hi,
I  have connected two MCU's through UART.
I want to send a string from MCU 1 to MCU 2.
once the MCU 1 sent the string it need to wait for some time to receive the reply from MCU 2.
If MCU 1 did not get any reply from MCU 2,it need to send back a string 'u there?'

How we can do this ?
I have tried the following with no success :-(
I am really vey new for programming forgive me if you find error,

uint8_t txBuffer[10] = "HELLO\r\n"
uint8_t txBufferN[15] = "u there ? \r\n"
uint8_t  rxBuffer[20] ;
HAL_UART_Transmit_DMA(&UartHandle, (uint8_t*)txBuffer, 10);
HAL_Delay(100);
HAL_UART_Receive_DMA(&UartHandle, (uint8_t*)rxBuffer, 20);

HAL_Delay(1000);

if(rxBuffer[0]=='H'&&rxBuffer[1]=='A'&&rxBuffer[2]=='I')

 

      {

 

          txBuffer[0]='C';

 

          txBuffer[1]='I';

 

          txBuffer[2]='A';

 

          txBuffer[3]='O';

 

          txBuffer[4]='\r';

 

         txBuffer[5]='\n';
       
        HAL_UART_Transmit_DMA
(&UartHandle, (uint8_t*)txBuffer, 10);
}
else
{
HAL_UART_Transmit_DMA(&UartHandle, (uint8_t*)txBufferN, 15);
}



Outcomes