2015-12-03 04:51 PM
Hi,
I tried using HAL_Delay(); I thought I can just use HAL_Delay(500); but it's not working.the code is below. (from STM32cubeF4)__weak void HAL_Delay(__IO uint32_t Delay){ uint32_t tickstart = 0; tickstart = HAL_GetTick(); while((HAL_GetTick() - tickstart) < Delay) { }}I found the first time tickstart = HAL_GetTick() is performed, the tickstart has the value 0. The second time, HAL_GetTick() returns some big value so it stays endlessly in while statement.Is there something I should do before using HAL_Delay()? #hal_delay2015-12-03 05:32 PM
I found the first time tickstart = HAL_GetTick() is performed, the tickstart has the value 0. The second time, HAL_GetTick() returns some big value so it stays endlessly in while statement.
Some big number minus zero is presumably bigger than 500? That would presumably exit the loop, so I'm confused. SysTick, with it's handler, must be functional for HAL_Delay() to work.
2015-12-04 05:31 AM
[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/uwTick%20not%20incrementing.%20%28HAL_Delay%28%29%29&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/AllItems.aspx¤tviews=9]Duplicate thread
Isn't the SysTick enabled/configured in HAL_Init() or something? And with handler code?/**
* @brief This function handles SysTick Handler.
* @param None
* @retval None
*/
void SysTick_Handler(void)
{
HAL_IncTick();
}
2015-12-04 06:38 AM