2021-12-19 10:25 PM
Want to use a ADC threshold on STM32F745 to wakeup the micro from Sleep. Table 14 (Features over all modes) in the reference manual, indicates that this support is O (optional i.e. Off by default but can be turned on by software). Can someone please elaborate on the exact process/sequence that needs to be followed to use a ADC threshold on STM32F745 to wakeup the micro from Sleep?
Thanks!
2021-12-20 03:15 AM
Hello LJain.1,
As you can see on the Reference Manual RM0385 (p.115), the MCU can exit from Sleep Mode by any interrupts " If the WFI instruction is used to enter Sleep mode, any peripheral interrupt acknowledged by the nested vectored interrupt controller (NVIC) can wake up the device from Sleep mode." including the ADC.
Before entering in Sleep Mode, you need to configure your ADC registers in order to generate an interruption when the analog voltage converted by the ADC is below a lower threshold or above a higher threshold. These thresholds are programmed in the 12 least significant bits of the ADC_HTR and ADC_LTR 16-bit registers. An interrupt can be enabled by using the AWDIE bit in the ADC_CR1 register. (For more details see Reference Manual RM0385 p.421 "Analog watchdog section").
It will be more easier for you to use STM32CubeMX to configure or ADC and generate your code on STM32CubeIDE or others IDEs.
There is an example of ADC1 configuration using STM32CubeMX. You need to enable the Analog WatchDog Interrupt and define your High/Low threshold. These thresholds are programmed in the 12 least significant bits (min 0 and max 4095) and the values depend on your VDDA voltage. (N.B : 0 and 3000 for the thresholds was just a example).
BR.
AMVE.1