I am developing a battery backed-up application with MKL36Z256VLL4 where the device enters VLLS1 when mains power is not available and wakes up as soon as mains power is available again. Power to MCU is supplied from the battery when there is no mains.
A 32-kHz crystal is connected to oscillator pins and the MCU runs at ~48 MHz during normal RUN mode. I am using FEE mode for MCG configuration. RTC clock source is selected as OSC32KCLK in SIM_SOPT1 register and works fine during RUN mode.
The device must keep date and time during RUN mode and VLLS1 mode. I am able make MCU to enter and exit VLLS1 successfully. Since it is a battery powered application I want to reduce sleep current as much as possible. To do this I want to turn off OSCERCLK before entering VLLS1. According to reference manual this should not harm RTC operation since RTC clock source is selected as OSC32KCLK in SIM_SOPT1 register and this clock source is not derived from OSCERCLK.
In order to keep RTC running during VLLS1, oscillator is kept ON (ERCLKEN = 1) always. However when EREFSTEN bit in OSCx_CR register is cleared before entering VLLS1, RTC stops working (time does not increment) until the MCU wakes up and reconfigures the oscillator with EREFSTEN = 1. If I do not clear EREFSTEN before entering VLLS1, RTC keeps track of time well during VLLS1 but this results in an increased sleep current.
What am I missing? How can I turn off OSCERCLK in VLLS1 mode while keeping the RTC run?