cancel
Showing results for 
Search instead for 
Did you mean: 

Restart SysTick after stop mode (HAL_Delay on infinite loop)

AKäfe.1
Associate II

I'm using a STM32F070CBT and putting it to stop mode with low power regulator on and waking it up with GPIO events.

In our project, we're using every single pin from the MCU, most of those are timers and GPIOs, NFC tag reader, etc

After waking it up, we're running some code and some delays, and the program is getting stuck on HAL_Delay callings. This is what we're initing again after waking it up from stop mode:

if(htim->Instance==TIM7)
{
		HAL_TIM_PWM_Stop(&htim3,TIM_CHANNEL_1);
	    __HAL_TIM_SET_COMPARE(&htim16,TIM_CHANNEL_1,0);
	    __HAL_TIM_SET_COMPARE(&htim17,TIM_CHANNEL_1,0);
	    HAL_GPIO_WritePin(LED_R_GPIO_Port,LED_R_Pin,1);
	    HAL_GPIO_WritePin(LED_G_GPIO_Port,LED_G_Pin,1);
	    HAL_GPIO_WritePin(LED_B_GPIO_Port,LED_B_Pin,1);
	    HAL_GPIO_WritePin(BLE_RESET_GPIO_Port,BLE_RESET_Pin,1);
	    HAL_GPIO_WritePin(MO2P_GPIO_Port, MO2P_Pin,1);
	    HAL_GPIO_WritePin(MO1P_GPIO_Port, MO1P_Pin,1);
	    st25r95SPIHibernate();
	    HAL_TIM_Base_Stop_IT(&htim7);
	    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFE);
	    SystemClock_Config();
	    
	   Systick1= SysTick->CTRL;
	    SysTick->CTRL = 0b011;
	    HAL_ResumeTick();
	   Systick2 = SysTick->CTRL;
	   HAL_GPIO_WritePin(LED_B_GPIO_Port,LED_B_Pin,0);
 
	   HAL_Delay(2);
	  __HAL_TIM_SET_COMPARE(&htim14,TIM_CHANNEL_1,400);
	   
 
	//	HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0)
 
	    hadc.State    = HAL_ADC_STATE_RESET;
	    huart3.gState = HAL_UART_STATE_RESET;
	    hspi1.State = HAL_SPI_STATE_RESET;
	    hspi2.State = HAL_SPI_STATE_RESET;
	    htim14.State = HAL_TIM_STATE_RESET;
 
 
	    MX_USART3_UART_Init();
	    MX_DMA_Init();
	    MX_ADC_Init();
	    MX_SPI1_Init();
	    MX_SPI2_Init();
	    HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_1);
 
 
	    reinit=1;
}

This function above is the first place the code returns after waking it up, so we've tried to reinit everything. These are some examples of what we've tried:

  • HAL_Init()
  • HAL_InitTick(0)
  • HAL_ResumeTick()
  • SysTick->CRTL = 0b011

Are we forgetting something or calling some functions on the wrong order, or is there another thing we're missing?

0 REPLIES 0