cnlohr / ch32v003fun

Open source minimal stack for the ch32 line of WCH processors, including the ch32v003, a 10¢ 48 MHz RISC-V Microcontroller - as well as many other chips within the ch32v/x line.
MIT License
901 stars 142 forks source link

How to read UART printf ? #396

Open hientv1999 opened 6 hours ago

hientv1999 commented 6 hours ago

Hi, I used to use noneos framework. I usually call USART_Printf_Init(9600) at the beginning of setup function before I start writing my debug message via printf. However, ch32v003fun framework doesn't support USART_Printf_Init(9600) function so I have removed this function in my main.c. I ran the debugprintfdemo example but don't get any signal on TX line. How can I still use TX line for UART printf? Simply doing printf obviously doesn't work on ch32v003fun for me.

BogdanTheGeek commented 5 hours ago

@hientv1999 debugprintf uses the debug port for printf, not uart. Check the uart examples and look for FUNCONF_USE_UARTPRINTF.

hientv1999 commented 5 hours ago

Can you please explain what is debug port? Is it the SWIO pin? If yes, how can I read the printf result? It would be great if I can free up the TX pin and use SWIO for printf

TommyMurphyTM1234 commented 5 hours ago

Can you please explain what is debug port? Is it the SWIO pin? If yes, how can I read the printf result? It would be great if I can free up the TX pin and use SWIO for printf

hientv1999 commented 5 hours ago

Can you please explain what is debug port? Is it the SWIO pin? If yes, how can I read the printf result? It would be great if I can free up the TX pin and use SWIO for printf

I already know this example code and compile but I see no output result (in serial monitor of course). By the way, using UART printf after toggling FUNCONF_USE_UARTPRINTF I can see printf result. But still no luck with SWIO printf

TommyMurphyTM1234 commented 5 hours ago

Can you please explain what is debug port? Is it the SWIO pin? If yes, how can I read the printf result? It would be great if I can free up the TX pin and use SWIO for printf

I already know this example code and compile but I see no output result.

You asked if it was using SWIO and I was confirming that it is.

TommyMurphyTM1234 commented 5 hours ago

Any use?

eeucalyptus commented 4 hours ago

To read the debug prints you can just use minichlink -T which can also most easily be called with make terminal with the ch32v003fun makefile