How to use two UARTs in paralell using K60

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to use two UARTs in paralell using K60

跳至解决方案
1,184 次查看
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;

}

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
971 次查看
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 项奖励
回复
1 回复
972 次查看
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 项奖励
回复