The CallBack_UART_Handle function is not functioning properly in the MC60 Open CPU environment

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

Hi
In my opinion, it is not that the uart call back was not triggered, but that the logic after triggering the call back was faulty, which led to your misjudgment of the phenomenon.
You can add a print to a function and watch the log output to see if the program is executing at the appropriate location.
For example:
switch (msg) {
case EVENT_UART_READY_TO_READ:
APP_DEBUG(“\r\n [uart_callback]read event start \r\n”);
len = Ql_UART_Read(port, buffer, sizeof(buffer));
APP_DEBUG(“\r\n [uart_callback]read len=%d \r\n”,len );
if (len > 0) {
buffer[len] = ‘\0’;
APP_DEBUG(“\r\n [uart_callback]write start\r\n”);
Ql_UART_Write(port, buffer, len);
}
break;

case EVENT_UART_READY_TO_WRITE:
    break;

default:
    break;

}

For the logic of callback, you can refer to the implementation of CallBack_UART_Hdlr in example_file.c and example_system.c

Hi Vincent,

I have checked the location in my code by printing .Facing the same issue it is not triggering callback uart handler . please help me with this issue.

Best regards,
Sourabh S Malsekar