cancel
Showing results for 
Search instead for 
Did you mean: 

How can i get printF to work in other .c files?

iwagg
Associate

I just started out a project with FreeRtos and followed this and managed to get it to work.

How to redirect the printf function to a UART for debug messages 

I can also printF from the freertos.c StartXXXTask functions.

But one of the start task functions i call my own method in my custom .C file i can't seem to printF from it. Within that function i can run this and it works, but not printF.

HAL_UART_Transmit(&huart2, buf, strlen((char*)buf), HAL_MAX_DELAY);

 

Wondering what am I doing wrong?

5 REPLIES 5
Andrew Neil
Evangelist III

@iwagg wrote:

 printF


Why the uppercase 'F' - is this some custom "wrapper" for the standard printf ... ?


@iwagg wrote:

But one of the start task functions i call my own method in my custom .C file i can't seem to printF from it.


What do you mean by that? It doesn't build? You get no output? Other...?

 

Apologies, that is my typo, it's not a custom wrapper.

 

It doesn't work as in no output. It compiles. Tried  putting a HAL uart transmit before and after the printf statement, those work and I get output, just no output from printf.

Does FreeRTOS have separate streams for each Task? Or require each Task to setup its own printf redirection?

If so, that would be a FreeRTOS question - not specific to STM32 ...

https://www.freertos.org/Documentation/RTOS_book.html

https://www.freertos.org/RTOS-contact-and-support.html

 

I think I'm unable to answer that. I'm new to STM32, C and embedded. Only have background in web frontend JS. 

 

Likely you haven't got the plumbing setup properly via _write() and __io_putchar()

Could try

char buf[64];

HAL_UART_Transmit(&huart2, (void *)buf, sprintf(buf, "%d\n", 123), HAL_MAX_DELAY);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..