cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 Wakeup Delay from Stop Mode (Stop 0)

Hailing SKY
Associate II
Posted on November 27, 2017 at 20:27

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.

0690X00000608ySQAQ.png

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.

0690X00000608ycQAA.png

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);

   }

  }

}

#stm32f4 #stop-mode #wakeup #stm32l4-hal
4 REPLIES 4
Hailing SKY
Associate II
Posted on November 28, 2017 at 22:52

Anyone has any ideas? I will be glad to hear any advices.

Hailing SKY
Associate II
Posted on December 01, 2017 at 15:35

Does ADC+DMA take time to start? If so, how to reduce the delay?

Hailing SKY
Associate II
Posted on December 01, 2017 at 17:35

Dear

Cherbonnel.Phili

‌,

Do you have any ideas to reduce the delay? I used the MSI clock (48 MHz) as the system clock after wakeup from the stop 0 mode. I guess the system should be active in 0.7 us and start to record the data (HAL_ADC_START_DMA), but from the data I got, the delay after the interrupt was around 30- 40 us. Do you know how to reduce the delay?

Best regards,

Hailing

Hailing SKY
Associate II
Posted on December 04, 2017 at 18:50

I found in the HAL_ADC_START_DMA function there are quite a few reduntant instructions and there is a time delay design in the ADC_ENABLE function for ADC stabilization. I guess that the reason for the delay. I will try it out later with simplifed codes.