cancel
Showing results for 
Search instead for 
Did you mean: 

ADC not running after wake from STOP2

CKugl.1
Senior II

I'm using STM32L412KBUx on NUCLEO-L412KB, STM32CubeIDE, Version: 1.8.0.

Design:

  • ADC1 is set up to continuously poll several channels and update locations in RAM with DMA.
  • After a period of inactivity, the application goes to sleep. COMP1 is used to detect a rising voltage on PA1 to wake up using an EVT.

Problem: After waking, the ADC does not seem to be running. The contents of the memory that holds the ADC readings just stay at their old values.

To enter STOP2, I'm using this:

		HAL_SuspendTick();
		__disable_irq();
		__DSB();
		__ISB();
		HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFE);
		// sleeping until wakeup event...

To wake:

		SystemClock_Config();
		HAL_ResumeTick();
		/* Exit with interrupts enabled. */
		__enable_irq();

I suspect I need to do something to restart the ADC clock.

I tried adding this before the STOP2 entry code above:

	if (HAL_OK != HAL_ADC_Stop_DMA(&hadc1))
		Error_Handler();

and this following the exit code:

	if (HAL_OK != HAL_ADC_Start_DMA(&hadc1, (void *)&raw_recs, ADC_RAW_REC_LEN))
		Error_Handler();

but it doesn't seem to make any difference.

Do I need to call something like HAL_RCCEx_PeriphCLKConfig, or perhaps HAL_RCCEx_WakeUpStopCLKConfig?

1 ACCEPTED SOLUTION

Accepted Solutions
CKugl.1
Senior II

Oh, never mind, I had a dumb logic error in my code. The ADC is indeed running.

View solution in original post

1 REPLY 1
CKugl.1
Senior II

Oh, never mind, I had a dumb logic error in my code. The ADC is indeed running.