AnsweredAssumed Answered

UART Testing in i.MXRT

Question asked by Anjalik Krishna on Jun 4, 2018
Latest reply on Jun 8, 2018 by Anjalik Krishna

Hi , 

    I am testing lpuart3 in i.MXRT 1050 evk board. Below is my code snippet

 

int main(void) {

uint8_t recv_buffer,recv_buffer1;

 

/* Init board hardware. */
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
/* Init FSL debug console. */
BOARD_InitDebugConsole();

BOARD_InitDataUart();

 

/*uart configuration*/
LPUART_GetDefaultConfig(&uart_config);
uart_config.baudRate_Bps= 115200U;
uart_config.enableTx = true;
uart_config.enableRx = true;

 

/*uart initialization*/
ret = LPUART_Init(LPUART3,&uart_config,UART_SRC_CLK);

/* Enter an infinite loop, just incrementing a counter. */
while(1) {

PRINTF("Data is being written \r\n");

recv_buffer1 = 9;

LPUART_WriteBlocking(LPUART3, &recv_buffer1, 1);

PRINTF("written data is %u",recv_buffer1);

PRINTF("Going to receive data Now:\r\n");

ret = LPUART_ReadBlocking(LPUART3,&recv_buffer,1);

PRINTF("Ret is %u",ret);

PRINTF("Received data is %u",recv_buffer);
}
return 0 ;
}

 

The rx tx lines are in loop back mode. But I am not getting the below prints

 

PRINTF("Ret is %u",ret);

PRINTF("Received data is %u",recv_buffer);

 

These two lines comes after LPUART_ReadBlocking .Since the function is in blocking mode how can I check the return status of this read function.

 

Is there any logical error in the code?

 

Could anyone suggest me the solution

 

Regards,

Anjali

Outcomes