tx_thread_sleep Hard Fault
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-08 11:33 AM
Hello
I am creating a project via STM32CubeIDE (V1.7.0) for a STM32F411 discovery including AzureRTOS.
When I include in my thread a call to tx_thread_sleep the program stops in HardFault_Handler when this function is called.
I have checked threads are created with no errors.
I changed this call by a delay with tx_time_get as in TX_thread_Creation example and this works correctly.
I am using the default configuration for AzureRTOS in the CubeMX, only changing "Timebase Source" to use a timer instead of systick and increased "ThreadX Memory pool size" to 10*1024 to avoid possible memory problems
Is there any known problem or change that must be made in configuration to solve this problem? Or there is something else that must be configured to solve this?
I include my code for App_threadX_Init, that I have checked with debuger that runs with no errors
UINT App_ThreadX_Init(VOID *memory_ptr)
{
UINT ret = TX_SUCCESS;
TX_BYTE_POOL *byte_pool = (TX_BYTE_POOL*)memory_ptr;
/* USER CODE BEGIN App_ThreadX_Init */
(void)byte_pool;
CHAR *pointer;
/* Allocate the stack for ThreadOne. */
if (tx_byte_allocate(byte_pool, (VOID **) &pointer,
256, TX_NO_WAIT) != TX_SUCCESS)
{
ret = TX_POOL_ERROR;
}
if (tx_thread_create(&ThreadOne, "Thread One", ThreadOne_Entry, 0,
pointer, 256,
3, 3,
TX_NO_TIME_SLICE, TX_AUTO_START) != TX_SUCCESS)
{
ret = TX_THREAD_ERROR;
}
/* Allocate the stack for ThreadTwo. */
if (tx_byte_allocate(byte_pool, (VOID **) &pointer,
256, TX_NO_WAIT) != TX_SUCCESS)
{
ret = TX_POOL_ERROR;
}
if (tx_thread_create(&ThreadTwo, "Thread Two", ThreadTwo_Entry, 0,
pointer, 256,
2, 2,
TX_NO_TIME_SLICE, TX_AUTO_START) != TX_SUCCESS)
{
ret = TX_THREAD_ERROR;
}
/* Create the event flags group. */
if (tx_event_flags_create(&EventFlag, "Event Flag") != TX_SUCCESS)
{
ret = TX_GROUP_ERROR;
}
/* USER CODE END App_ThreadX_Init */
return ret;
}
And my two threads functions
void ThreadOne_Entry(ULONG thread_input)
{
/* User can add his own implementation*/
while(1){
// tx_thread_sleep(1);
HAL_GPIO_TogglePin(LD4_GPIO_Port, LD4_Pin);
// App_Delay(100);
tx_thread_sleep(10);
}
}
void ThreadTwo_Entry(ULONG thread_input)
{
/* User can add his own implementation*/
while(1){
// tx_thread_sleep(1);
HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
// App_Delay(100);
tx_thread_sleep(100);
}
}
Solved! Go to Solution.
- Labels:
-
AzureRTOS
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-14 4:53 AM
Hi @Community member​
the issue is with the stack size, using only 256 bytes seems to be not enough.
Could you try with 1024 ?
regards
Haithem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-14 4:53 AM
Hi @Community member​
the issue is with the stack size, using only 256 bytes seems to be not enough.
Could you try with 1024 ?
regards
Haithem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-14 1:58 PM
Hello Haithem
Thanks for your answer.
Yes, that solved the problem
Kind regards
