Unable to wake up the STM32CO from the stop mode by using the I2C.
Hi,
I have made the STM32C0 an I2C slave, and I want to wake up the STM32C0 from the stop mode by using the I2C. I have tried with the below configurations, but STM32C0 won't wake up when any I2C events occur. When the device is in running mode, I2C works fine.
I2C_config(){
hi2c1.Instance = I2C1;
hi2c1.Init.Timing = 0x40000A0B;
hi2c1.Init.OwnAddress1 = 64;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK) {
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE)
!= HAL_OK) {
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN I2C1_Init 2 */
// Enable and set I2C interrupt priority
HAL_NVIC_SetPriority(I2C1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(I2C1_IRQn);
__HAL_I2C_ENABLE_IT(&hi2c1, I2C_IT_ADDRI);
}
/**************Stop mode configuraions***************/
StopModeConfig(){
HAL_I2CEx_EnableWakeUp(&hi2c1);
// __HAL_I2C_ENABLE_IT(&hi2c1, I2C_IT_ADDRI); // TBD: Use the I2C as a Wake-up source
HAL_SuspendTick();
HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);
HAL_ResumeTick();
}
I have also tried with the below lines before entering into the stop mode.
HAL_I2C_DisableListen_IT(&hi2c1);
HAL_I2CEx_EnableWakeUp(&hi2c1);
HAL_I2C_EnableListen_IT(&hi2c1);
When I use the sleep mode instead of stop mode, the device can wake up on i2c events. I need help to wake up the STM32C0 from the stop mode when any I2C event occurs.
Thanks
