Quecopen uart 1 debug uart not working

I would like to interface an external sensor via uart. I am using the olimex bc66 dev kit, the one with the usb port.

I am using quecopen and can see uart debug via uart0 app_debug. So I thought perhaps I could use uart1 (debug uart)?

I tried to use the API ql_uart… But nothing is coming out of the pin (39) when viewed on a scope. I get no error returned from register or open api and sent bytes matches what id expected from ql_uart_write.

Please help!

Do I need to disable some default usage of these ports?
I noticed wizio seemed to access registers directly, is that before of an issue with the API? If so, where is this register details documented

Code is very simple. No sleep. No while (1).

1 Like

Hi James,

I am using the UART_PORT1 succesfully, therefore it can de used. Please check this file: …/custom/config/custom_sys_cfg.h. debugPortCfg has to be set in BASIC_MODE:


static const ST_DebugPortCfg debugPortCfg = {
BASIC_MODE // Set the serial port to a common serial port
//ADVANCE_MODE // Set the serial port to a special debug port
};

Then you have to resgister and open the UART in the main.c:


/* Register UART port for reading data /
ret = Ql_UART_Register(UART_PORT1, CallBack_UART_Hdlr, NULL);
if (ret != QL_RET_OK) {
Ql_Debug_Trace("[ERROR] Fail to Ql_UART_Register port[%d]: %d\r\n", UART_PORT1, ret);
}
/
Open UART port for reading data */
ret = Ql_UART_Open(UART_PORT1, 115200, FC_NONE);
if (ret != QL_RET_OK) {
APP_DEBUG("[ERROR] Fail to Ql_UART_Open port[%d]: %d\r\n", UART_PORT1, ret);
} else {
APP_DEBUG("[INFO] UART Port %d open for reading data\r\n", UART_PORT1);
}

And then, you have to define your callback: CallBack_UART_Hdlr.

That is all you have to do.

Best regards.

Also remember that the power domain is 1.8V. Therefore you should probably have to use a level shifter.

Best regards.

Thanks so much. This looks a lot like the code I had tried.

Then you just use Ql_uart_write?

Is it blocking? And can be used similar to how app_debug “printf” is in the examples?

I suppose what I’m trying to confirm is also that you use two uarts at the same time?

Yes, I am using two uarts at the same time, but only for reading. I dind’t have to use the function Ql_UART_Write. => I am sorry, I was wrong. I am using one only for reading and the other one only for writing.

Ok thanks. I will try again, to be honest app_drbug didn’t work when I switched from port 0 to 1 so you have that working.

I am sorry, APP_DEBUG is a macro made for me. You have to use this:

Ql_UART_Write((Enum_SerialPort)(DEBUG_PORT), (u8 *)(DBG_BUFFER), Ql_strlen((const char *)(DBG_BUFFER)));

Best regards.

All sorted. A mix up on port 1 and 2 pinout and bugs in callback. To confirm, can use multiple uarts. Advice from Oscar is good stuff

1 Like