2023-02-24 10:20 AM
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?
Solved! Go to Solution.
2023-02-25 07:19 PM
extern UART_HandleTypeDef huart2;
2023-02-24 10:43 AM
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?
2023-02-24 03:20 PM
I get the same error. So the fix was to add #include "main.h" to the app_threadx.c file
2023-02-25 05:02 AM
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?
2023-02-25 08:15 AM
Well "HAL_UART_Transmit function does not work" is kind of vague. You need to describe the issue in more detail.
2023-02-25 05:32 PM
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.
2023-02-25 07:19 PM
extern UART_HandleTypeDef huart2;