cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_UART functions do not work with Azure RTOS ThreadX

MStew.1
Associate III

Hello,

I followed this guide:

https://community.st.com/s/article/how-does-the-threadx-semaphore-work

And everything works.

But when I try to add a modification, a HAL_UART_Transmit - HAL_UART_Transmit(&huart2, (uint8_t *)&message, 1, 10); - in one thread I always get the error 'huart2' undeclared. Well huart2 is declared in my main.c but of course not in the app_thread.c. And there are my threads.

So my question is how can I solve this error? With FreeRTOS I just created threads and all the code in my main.c so there was no issue to use HAL_UART. But I am not sure how to solve it on ThreadX?

1 ACCEPTED SOLUTION

Accepted Solutions
Karl Yamashita
Lead II

extern UART_HandleTypeDef huart2;

If you find my answers useful, click the accept button so that way others can see the solution.

View solution in original post

6 REPLIES 6
MStew.1
Associate III

The same for HAL_GPIO_WritePin or HAL_GPIO_TogglePin.. I am not able to use them with Azure RTOS in the threads in the app_threadx.c file. Is there a way to be able to use them?

Karl Yamashita
Lead II

I get the same error. So the fix was to add #include "main.h" to the app_threadx.c file

If you find my answers useful, click the accept button so that way others can see the solution.
MStew.1
Associate III

Thank you @Community member​ this solved the problem with the LEDs, the HAL_GPIO_WritePin or HAL_GPIO_TogglePin works. But still the HAL_UART_Transmit function does not work in the app_threadx.c file. Do you know how to solve this too?

Karl Yamashita
Lead II

Well "HAL_UART_Transmit function does not work" is kind of vague. You need to describe the issue in more detail.

If you find my answers useful, click the accept button so that way others can see the solution.

So I followed this guide:

https://community.st.com/s/article/how-does-the-threadx-semaphore-work

And everything works as expected.

But I wanted to modify the example. I added in my app_threadx.c file in my threads the

HAL_UART_Transmit and HAL_UART_Receive functions. I initialized the uart in the CubeMX configurations so its in there.

But the problem I face is the following: Since I add all my code in the app_threadx.c and so my uart transmit and receive functions in my threads I get the error when I try to build: 'huart2' undeclared - The uart2 is declared in my main.c file but not in the app_threadx.c.

So how can I use uart transmit and uart receive in my threads?

With FreeRTOS it was straight forward, as I did all the code in the main.c so I could use the uart transmit and receive functions in my threads out of the box as it was all in the main.c file.

Karl Yamashita
Lead II

extern UART_HandleTypeDef huart2;

If you find my answers useful, click the accept button so that way others can see the solution.