AnsweredAssumed Answered

STM32L4 Wakeup Delay from Stop Mode (Stop 0)

Question asked by Hailing SKY on Nov 27, 2017
Latest reply on Dec 4, 2017 by Hailing SKY

Question: How to achieve the 4.5 us wakeup time for the stop mode (Stop 0)? The board I am using is STM32L476 NucLeo. I am using the MSI clock (48 MHz) as the system clock. After awaken up, the MCU runs the 'HAL_ADC_START_DMA' instruction immediately. However, it still takes roughly 40 us to start recording. Any idea what causes the delay?

 

I am using STM32L476 for data acquisition and local processing. The data are collected using ADC+DMA in the continuous mode. I would like to make the system operate in the sleep mode when there is no data recording required, and wake the system up as quick as possible when there is an external interrupt (PA0) and start data recording.

 

Fig.1 STM32F476 Datasheet - low power modes

 

I found in the STM32L476 datasheet that the wakeup time is several us (0.7 - 6 us) for different stop modes. This is good enough for my application. However, when I tested it, the wakeup time was much longer than the one showed in the datasheet. The wakeup time was like 30 us, as shown in Fig. 2. The input for the interrupt (PA0) was also the original signal (Blue line). The threshold was tested as 1.8 V.

Fig.2 Tested Result - Original & Recorded Signal.

 

I am wandering if this difference was caused by my codes. Please let me know if you have any idea. My codes for the low power mode was as follows.

 

int main(void)
{

HAL_Init();
SystemClock_Config();

 

/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
MX_USART1_UART_Init();

// using MSI clock for system clock after wake-up
__HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_MSI);


// Stop mode - interrupt to wake up
HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON,PWR_STOPENTRY_WFI);

 

HAL_ADC_Start_DMA(&hadc1,(uint32_t*)adcValue,BUF_SIZE*CHANNEL_COUNT);


 while (1)
 {
   if (indi_led == 1)
   {
     HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);

 

     HAL_UART_Transmit(&huart1,(uint8_t*)datastore1,BUF_SIZE,3000);
     indi_led = 0;
     HAL_Delay(3000);


     HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON,PWR_STOPENTRY_WFI);

     HAL_ADC_Start_DMA(&hadc1,(uint32_t*)adcValue,BUF_SIZE*CHANNEL_COUNT);
   }

  }

}

Outcomes