How to use two UARTs in paralell using K60

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

How to use two UARTs in paralell using K60

Jump to solution
650 Views
dkarthik
Contributor II

I would like to make the K60 MCU

-> Receive from a UART5(connected to PC) and send it to another UART3(connected to a device)

-> Receive from UART3(connected to device) and send it to UART5(connected to PC)

I set the AS1:serial_LDD to UART5 and AS2:serial_LDD to UART_3.

I referred typical usage of Serial_LDD component in processor expert at polling mode and wrote the following code. The AS1_serial component works. It receives the characters from PC and echoes back but I think AS2_component gets struck in receiving characters.  Please review and the code and help me debug. I would like to know If there is any problem with the code. Thank you.

MySerialPtr1 = AS1_Init(NULL); /* Initialization of AS1 component *

MySerialPtr2 = AS2_Init(NULL); /* Initialization of AS2 component */

for(;;) {

while(1) {

Error1 = AS1_ReceiveBlock(MySerialPtr1, InpData1, 1U); // Start reception of one character

while (!DataReceivedFlg1) { // Wait until a character is received

AS1_Main(MySerialPtr1);

}

Error1 = AS1_SendBlock(MySerialPtr1, InpData1, sizeof(InpData1)); // Echo to terminal in PC

Error2 = AS2_SendBlock(MySerialPtr2, InpData1, sizeof(InpData1)); // Send to device

if (InpData1[0] == '\r') { // If enter key is received break from the while loop

break; }

DataReceivedFlg1 = FALSE;

}

while(1) {

Error2 = AS2_ReceiveBlock(MySerialPtr2, InpData2, 1U); // Start reception of one character from the device

while (!DataReceivedFlg2) { // Wait until a character is received

AS1_Main(MySerialPtr2);

}

Error1 = AS1_SendBlock(MySerialPtr1, InpData2, sizeof(InpData2)); // Send it to PC

if(InpData2[0] == '>') { //If '>' is received break from the while loop

break; }

DataReceivedFlg2 = FALSE;

}

DataReceivedFlg1 = FALSE;

DataReceivedFlg2 = FALSE;

}

Labels (1)
Tags (2)
0 Kudos
1 Solution
437 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi!

There was a documentation problem with UART3 pins which was already reported. Please try with PTE4 and PTE5. Please refer to the following thread.

https://community.freescale.com/thread/318524


Regards,

Carlos

View solution in original post

0 Kudos
1 Reply
438 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi!

There was a documentation problem with UART3 pins which was already reported. Please try with PTE4 and PTE5. Please refer to the following thread.

https://community.freescale.com/thread/318524


Regards,

Carlos

0 Kudos