I'm encountering an issue with the STM32 internal comparator (COMP). Although the signal comparison works as expected, I've observed that enabling the COMP causes a significant increase in current consumption, specifically 195uA in stop mode. I'm using the appropriate APIs to de-initialize the COMP when entering stop mode, but the current consumption remains high. Any insights or suggestions on how to address this issue would be greatly appreciated.
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_SuspendTick(); // Disable all the system Interrupts ticks
HAL_COMP_DeInit(&hcomp1); // Deinitializing the COMPARATOR while Entering to the STOP mode
HAL_PWR_EnableSleepOnExit(); // Enable the Sleep on External Interrupt
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
}
/* USER CODE BEGIN 4 */
void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp) // COMP1_ISR
{
SystemClock_Config(); // Initialized the clock function again as it was suspended
HAL_ResumeTick(); // Resume the systick now you can use delay
HAL_PWR_DisableSleepOnExit(); // Disable the Sleep on EXIT
}
/* USER CODE END 4 */
I'm trying to understand the reason behind the significant increase in current consumption (195uA) when enabling the internal comparator (COMP) on an STM32 MCU. I'm using the correct APIs to de-initialize the COMP when entering stop mode, but the issue persists. I've attached Figure01 (current consumption when COMP is disabled) and Figure02 (current consumption when COMP is enabled) for reference. Can anyone help identify the potential cause of this higher current consumption or point out any issues in the provided functions for entering stop mode? Your insights would be highly valuable.
Fig#01 (Microcontroller stop Mode current)
Fig#02(Microcontroller and internal comparator current consumption in stop Mode)
I've implemented the code as described above, anticipating that the overall current consumption should not exceed 5uA as per datasheet https://www.st.com/en/microcontrollers-microprocessors/stm32l431rc.html, as indicated in Figure #01. However, it appears that the internal comparator may not be entering stop mode correctly. The final current (MCU + COMP) is unexpectedly high at almost 200uA, as depicted in Figure #02. I've ensured proper use of the provided functions for entering stop mode. Could someone help me understand why the internal comparator is not properly entering stop mode, leading to this substantial increase in current consumption? Any insights or suggestions would be greatly appreciated. Thank you!