Hi
The CallBack_UART_Handle function for Enum_SerialPort doesn’t work in the MC60 Open CPU environment.
The write operation works correctly, but only the data reception from the port does not function properly. It seems that the CallBack_UART_Handle
function is not being called.
I am using UART1 on the MC60 module and I am confident about the correct connection of the TX and RX lines, as I use the same port to upload compiled code for the Open CPU feature, and the code is successfully uploaded to the module. Below, I will show the example code I used.
#include “ql_system.h”
#include “ql_uart.h”
#define SERIAL_PORT UART_PORT1
static void CallBack_UART_Handle(Enum_SerialPort port, Enum_UARTEventType msg, bool level, void* customizedPara) {
s32 len;
u8 buffer[100];
switch (msg) {
case EVENT_UART_READY_TO_READ:
len = Ql_UART_Read(port, buffer, sizeof(buffer));
if (len > 0) {
buffer[len] = '\0';
Ql_UART_Write(port, buffer, len);
}
break;
case EVENT_UART_READY_TO_WRITE:
break;
default:
break;
}
}
void proc_main_task(s32 taskId) {
Ql_UART_Register(SERIAL_PORT, CallBack_UART_Handle, NULL);
Ql_UART_Open(SERIAL_PORT, 115200, FC_NONE);
u8* initMsg = "UART Ready!\r\n";
Ql_UART_Write(SERIAL_PORT, initMsg, Ql_strlen(initMsg));
while (TRUE) {
Ql_Sleep(100);
}
}
More information:
Module: MC60 OpenCPU
SDK Version: 1.8v
IDE: VS Code
UART Port: UART1
Communication App: PuTTY