2022-08-30 07:49 AM
If Azure ThreadX is enabled, Systick no longer updates; HAL_IncTick() is no longer called from the interrupt, and initialization fails.
Solved! Go to Solution.
2022-08-31 08:05 AM
I was able to fix this and move forward.
So ThreadX "steals" the SysTick interrupt from the HAL. The priorities seem fine. But the HAL interrupt handler calls HAL_IncTick, and when ThreadX is enabled, it no longer gets called (ThreadX has it's own version of SysTick interrupt handler). So I enabled TIM2. You have to move the init code for TIM2 above the rest of the HAL init:
/* USER CODE END Boot_Mode_Sequence_2 */
/* USER CODE BEGIN SysInit */
MX_TIM2_Init(); // timer must be started before using HAL, it replaces SysTick
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DSIHOST_DSI_Init();
MX_FMC_Init();
and start the timer in MX_TIM2_Init():
/* USER CODE BEGIN TIM2_Init 2 */
HAL_TIM_Base_Start_IT(&htim2); // Enable the interrupt & start the timer
/* USER CODE END TIM2_Init 2 *
then call the SysTick function from the interrupt:
void TIM2_IRQHandler(void)
{
/* USER CODE BEGIN TIM2_IRQn 0 */
/* USER CODE END TIM2_IRQn 0 */
HAL_TIM_IRQHandler(&htim2);
/* USER CODE BEGIN TIM2_IRQn 1 */
HAL_IncTick(); // Need to emulate the SysTick to enable HAL initialization
/* USER CODE END TIM2_IRQn 1 */
}
HTH someone...
2022-08-31 02:43 AM
check your NVIC preemption
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
and your systick priority
HAL_InitTick(TICK_INT_PRIORITY);
speciall atention to this part inside HAL_InitTick
/* Configure the SysTick IRQ priority */
if (TickPriority < (1UL << __NVIC_PRIO_BITS))
{
HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
uwTickPrio = TickPriority;
}
else
{
return HAL_ERROR;
}
, there is a good chance threadX NVIC setup is bullying your systick interruption setup.
2022-08-31 08:05 AM
I was able to fix this and move forward.
So ThreadX "steals" the SysTick interrupt from the HAL. The priorities seem fine. But the HAL interrupt handler calls HAL_IncTick, and when ThreadX is enabled, it no longer gets called (ThreadX has it's own version of SysTick interrupt handler). So I enabled TIM2. You have to move the init code for TIM2 above the rest of the HAL init:
/* USER CODE END Boot_Mode_Sequence_2 */
/* USER CODE BEGIN SysInit */
MX_TIM2_Init(); // timer must be started before using HAL, it replaces SysTick
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DSIHOST_DSI_Init();
MX_FMC_Init();
and start the timer in MX_TIM2_Init():
/* USER CODE BEGIN TIM2_Init 2 */
HAL_TIM_Base_Start_IT(&htim2); // Enable the interrupt & start the timer
/* USER CODE END TIM2_Init 2 *
then call the SysTick function from the interrupt:
void TIM2_IRQHandler(void)
{
/* USER CODE BEGIN TIM2_IRQn 0 */
/* USER CODE END TIM2_IRQn 0 */
HAL_TIM_IRQHandler(&htim2);
/* USER CODE BEGIN TIM2_IRQn 1 */
HAL_IncTick(); // Need to emulate the SysTick to enable HAL initialization
/* USER CODE END TIM2_IRQn 1 */
}
HTH someone...
2022-09-01 12:34 AM
youre the best answer then! congrats