UART configuration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART configuration

948 Views
ambarishhundeka
Contributor III

Hi NXP Team,

I have tried example code of UART given by the NXP.

I am able to send the data from the controller to PC but not able to receive the data from PC(realTerm tool).

attached the example code .

char LPUART1_receive_char(void) { /* Function to Receive single Char */
char recieve;
while((LPUART1->STAT & LPUART_STAT_RDRF_MASK)>>LPUART_STAT_RDRF_SHIFT==0);
/* Wait for received buffer to be full */
recieve= LPUART1->DATA; /* Read received data*/
return recieve;
}

always while condition is failed and not able to update the receive data(RDRF bit is always 0).

Regards,

Ambarish

Labels (1)
1 Reply

620 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Ambarish,

I assume when you increment value i and when some character is null, (i+'0') should help.

Could you try this code?
while(1)
{
      LPUART1_recieve_and_echo_char();
      LPUART1_transmit_char(i+'0');
      i++;
      if(i == 100) {  i = 0; }
}

Note:
LPUART1_receive_char(); - this function wait for the character and return receive character. If you want to see the receive character you should call LPUART1_recieve_and_echo_char(); - this function transmit the receive char back to the sender, after that you could see your character on the terminal.

I hope it helps you.

Best regards,

Diana