cancel
Showing results for 
Search instead for 
Did you mean: 

waking from stop mode

PToma.14
Associate II

I am using stop mode for saving power. My board has dcmi interface for camera ov2640. When I wake up from stop the camera doesn't work. What is the proper way for waking up from STOP mode? Following is the code I am using for STOP mode

void stopMode(void)
{
  HAL_SuspendTick();
  MX_GPIO_Deinit();
  __HAL_RCC_PWR_CLK_ENABLE();
  HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
}
 
void MX_GPIO_Deinit()
{
	GPIO_InitTypeDef GPIO_InitStruct;
	__HAL_RCC_GPIOA_CLK_ENABLE();
	__HAL_RCC_GPIOB_CLK_ENABLE();
	//__HAL_RCC_GPIOC_CLK_ENABLE();
	__HAL_RCC_GPIOH_CLK_ENABLE();
 
	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Pin = GPIO_PIN_All;
	HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
	//HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
	HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
 
	/* Disable GPIOs clock */
	__HAL_RCC_GPIOA_CLK_DISABLE();
	__HAL_RCC_GPIOB_CLK_DISABLE();
	//__HAL_RCC_GPIOC_CLK_DISABLE();
	__HAL_RCC_GPIOH_CLK_DISABLE();
}
 
void resumeStopMode(void)
{	SystemClock_Config();
	HAL_ResumeTick();
}

I use resumeStopMode function after board is woken up by GPIO ext interrupt.

3 REPLIES 3
Mohamed Aymen HZAMI
ST Employee

Hello,

Which product do you use?

Best Regards,

Mohamed Aymen.

PToma.14
Associate II

Hi I am using STM32F446RCTx. We have a custom board with this microcontroller. Problem is that if I do MX_GPIO_Deinit() before going into stop mode for maximum power the ov2640 i2c, dcmi stops working. If I don't call MX_GPIO_Deinit before going into stop then it camera work fine.

Mohamed Aymen HZAMI
ST Employee

Hello,

  1. Which pin are you using to interface the camera ?
  2. In case that the pin that you using are in the MX_GPIO_Deinit function :
  • In this way the configuration you made to interface them with the camera are losing because you put them all to analog state.
    • To keep the state of the GPIO you are using with the camera you need to do like this :
      • for example in case that you use GPIOA_PIN1 and GPIOA_PIN2 :
void MX_GPIO_Deinit()
{
	GPIO_InitTypeDef GPIO_InitStruct;
	__HAL_RCC_GPIOA_CLK_ENABLE();
	__HAL_RCC_GPIOB_CLK_ENABLE();
	//__HAL_RCC_GPIOC_CLK_ENABLE();
	__HAL_RCC_GPIOH_CLK_ENABLE();
 
	GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Pin = GPIO_PIN_All;
	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
	//HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
	HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
        
        GPIO_InitStruct.Pin = GPIO_PIN_All & (~GPIO_PIN_1) & (~GPIO_PIN_2);
        HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
 
	/* Disable GPIOs clock */
	__HAL_RCC_GPIOA_CLK_DISABLE();
	__HAL_RCC_GPIOB_CLK_DISABLE();
	//__HAL_RCC_GPIOC_CLK_DISABLE();
	__HAL_RCC_GPIOH_CLK_DISABLE();
}

Best Regards,

Mohamed Aymen.