2023-08-18 02:35 AM
I am using a nucleo-f767zi to control a reverdi tft display.
The project in CUBEMX ide is using freertos and there for the time base is changed from systick to TIM6.
I am trying to task enable sequence for the screen but i see that i am stack in an infinite loop in HAL_delay() function.
I debbugged it and i see that when i stepped into the code program stops at :
__weak void HAL_Delay(uint32_t Delay)
{
uint32_t tickstart = HAL_GetTick();
uint32_t wait = Delay;
/* Add a freq to guarantee minimum wait */
if (wait < HAL_MAX_DELAY)
{
wait += (uint32_t)(uwTickFreq);
}
// it is blocked in side this loop. which means that HAL_GetTick() has issue.
while ((HAL_GetTick() - tickstart) < wait)
{
}
}
It seems that HAL_GetTick has issue so this means that i am missing some setup.
Can you someone guide me where to look?
Project identifies TIM6 as base time and the interrupt is there in ioc
Solved! Go to Solution.
2023-08-18 06:15 AM
When it's stuck:
2023-08-18 02:43 AM - edited 2023-08-18 02:44 AM
Hello @Kyrpav,
Check/ live watch the HAL_GetTick() function to see if it's returning the correct value, also check the tick freq in the HAL_InitTick()
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-08-18 06:15 AM
When it's stuck:
2023-08-18 08:34 AM - edited 2023-08-18 09:34 AM
The HAL_GetTick() gives same value all time in each loop. this value is thevalue that gets until it gets in this while loop then the value does not change at all.
About interrupt high priority i have (or i did not know where to look for this.)
I changed the priority from 15 to 0 but Hal_InitTick is i think for SysTick based on what i see in code except if i am wrong.
for the TIM6->DIER from the SFRs view and the registers o see that value is always 1 but CNT registart changes in every step over.
__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
{
/* Configure the SysTick to have interrupt in 1ms time basis*/
if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) > 0U)
{
return HAL_ERROR;
}
/* Configure the SysTick IRQ priority */
if (TickPriority < (1UL << __NVIC_PRIO_BITS))
{
HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
uwTickPrio = TickPriority;
}
else
{
return HAL_ERROR;
}
/* Return function status */
return HAL_OK;
}
Do i need to make changes in this file and what stm32f7xx_hal.c for th e Hal_InitTick()? Am i suppose to change this file at all or it is something else that needs to be done?
Thank you @Sarra.S and @TDK for trying to help
2023-08-18 12:02 PM
Okay so DIER=1 and the timer is running, which means the interrupt wants to fire. The NVIC bit also needs set but I bet it is. Now you need to determine why it's not firing. Probably interrupts are disabled, or you're running in a higher-priority interrupt.
Where are you calling HAL_Delay from?
Show the contents of the SCB registers, in particular ICSR.
2023-08-18 01:42 PM - edited 2023-08-18 01:42 PM
For the interrupt and the priorities i have from ioc this:
This does not mean that it is ok? I also tried to make tim6 also priority = 0 from 15 but no change
And from the freertos i have two tasks with normal priority
The Hal_delay i am calling it inside the main.c i am doing it after touchgfx init and before osKernel and freertos init.
As you see i am trying to make disp pin to go HIgh and to identify it without checking pin cause i do not now how to do it in debug from software side easily i use also one of the leds of the nukleo board.
For the contents of the SCB registers, in particular ICSR what am i expecting to see as proper behaviour?
2023-08-18 02:45 PM - edited 2023-08-18 04:04 PM
Sorry for the delay. it seems that after Hal_Init function i have this stable
and after letting it too much time stuck in the while loop i see also
Tried also to enable interupts with __enable_irq() or should i try to enable interrupt only for tim6 like :
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_LTDC_Init();
MX_DMA2D_Init();
MX_CRC_Init();
MX_TouchGFX_Init();
/* Call PreOsInit function */
MX_TouchGFX_PreOSInit();
/* USER CODE BEGIN 2 */
__enable_irq();
HAL_Delay(10);
HAL_GPIO_WritePin(LTDC_DISP_GPIO_Port, LTDC_DISP_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_SET);
HAL_Delay(250);
HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_RESET);
/* USER CODE END 2 */
And for the sysTick is see:
Trying to enable it with HAL_NVIC enable irw i found this strange thing that the TIM6 irq defined by the system it self includes DAC on the name :
HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
Also if you see previous posts for ioc and NVIC page it says "Time base: TIM6 global interrupt, DAC1 and DAC2 ...
but i have nothing set for DAC
Maybe link to zip file with the project could also help
https://mega.nz/file/SlUQCARA#UqG_ZCWWC0KIs_FuVe785gZQrhLI05bTdZ94X5lUydA
2023-08-19 09:46 AM
I seems that when i set TIM6 priority at for which means more than LTDC it worked.
then i think i burned stlink but i opened another ticket for this. about the priorities is this the proper or the setup should be different in general