This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

cmsis-rtos v2 - printf not working inside threads

Hello,

I am working with STM32WB55RG platform. I have successfully use printf function with uart. However when I try to use this same function inside cmsis-rtos v2 threads it's not working. Basically thread hangs.

My code implementing printf:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifdef __GNUC__
/* With GCC, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
PUTCHAR_PROTOTYPE
{
/* Place your implementation of fputc here */
/* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Code starting thread:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// ...
osKernelInitialize();
const osThreadAttr_t main_attributes = {
.name = "main",
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 1024
};
mainHandle = osThreadNew(mainFunction, NULL, &main_attributes);
osKernelStart();
// ...
void mainFunction(void *argument)
{
uint8_t message[40] = "Hello World! This is mine.\n\r";
for(;;)
{
printf("Hello this is printf!\n");
//HAL_UART_Transmit(&huart1,message,sizeof(message),10);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

If I remove printf HAL_UART_Transmit works properly. Any thoughts?

Best regards,

zurek

0