Discovery board STM32L0 (LoRaWAN) -> How to configure the stop mode correctly?
Hello!
I come there after some days of work on the stop mode on the dicovery board STM32L0 with LoRaWAN.
I tried to generate a new project which does nothing, to test the stop mode with RTC following the datasheet and measure the current consumption. I have some issues with doing this.
I use a multimeter on the JP2 tu measure the consumption when the board is powered by USB. Without the stop mode, the consuption is arround 11 mA and when I activate the stop mode after suspending Tick, the current consumption is arround 3.1 mA, which still is far far away from the consumption mentioned in the datasheet.
You can find my main following, maybe you can help me to find how can I enter in stop mode correctly? :smiling_face_with_smiling_eyes:
Thank you for your help !
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_RTC_Init();
MX_SPI1_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
/* LOW POWER CODE */
HAL_Delay(1000);
HAL_SuspendTick();
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_EnableUltraLowPower(); // Ultra low power mode
HAL_PWREx_EnableFastWakeUp(); // Fast wake-up for ultra low power mode
HAL_DeInit();
MX_GPIO_Disable();
// TCXO disabled with JP9 on 1-2
__HAL_RCC_SPI1_CLK_DISABLE();
__HAL_RCC_USART2_CLK_DISABLE();
__HAL_RCC_ADC1_CLK_DISABLE();
__HAL_RCC_TIM21_CLK_DISABLE();
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); // clear wake up flag
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
HAL_ResumeTick();
SystemClock_Config();
/* LOW POWER CODE END */
/* Infinite loop */
while (1)
{
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_RESET);
HAL_Delay(500);
}
}