I am in the process of switching from the B SoM to M SoM for several products. I'm trying to figure out how to get the M SoM to wake up from hibernation using a GPIO pin like I have with the B SoM. Based on my reading of the docs, it should be possible using the same approach.
I have a digital line (A7) that I am using to put the device into hibernate and wake it (essentially, it's watching for mains power). Currently, the device goes into hibernation just fine using the code below, but the only way I can get it to wake up is to manually press "RESET".
It is my own board and using a similar design used for the past few years successfully. The pin is set as INPUT_PULLDOWN, so using the MCU's internal pulldown.
I am reading from a voltage divider that converts the 12V mains power to a 0-~3.3V signal. I've checked the voltages and everything appears to work as expected as far as that goes, but it's not triggering he wake up of the MCU.
Thanks for the update @rickkas7 - I'm glad it's not just me! I'll keep working on it and post any updates here and will check back to see if Particle learns anything as well.
Hi @hagandh , I built exactly the same code that @rickkas7 posted above for MSoM that is installed on M.2 SoM Breakout board against DVOS@5.9.0 and it appeared to be working as expected, no matter whether pinMode(PIN_MAINS_ACTIVE, INPUT_PULLDOWN); is called or not. Just make sure that the A7 is not used by other peripherals, for example, if the MSoM is ever configured for Particle Muon , the A7 is then used by DVOS as PMIC interrupt, see device-os/user/applications/tinker/src/board_config.cpp at develop · particle-iot/device-os · GitHub
As it turns out, there is an important difference between engineering samples of the M-SoM and the production version.
On the production M-SoM, pin A7/D28/WKP is on M.2 pin 47 and MCU pin PA[20]. This is what is documented in the datasheet.
On engineering samples, which is what I had used to test as well, M.2 pin 47 is VBAT_MEAS and PA[20] is on M.2 pin 57, SOM17 on the M.2 breakout board.
A production M-SoM works correctly using A7 to wake on the breakout board pin A7 (M.2 pin 47).
On an EVT sample, if you move the wake source to SOM17 (M.2 pin 57) it behaves as if it was A7.
Can confirm I was using an engineering sample previously. I have switched to a non-engineering sample, but do still have issues, though likely due to implementation.
I'm trying to read a 12-16V mains power signal and shut down when mains is turned off and back on when it's turned on. Simple enough. I have a voltage divider set up to drop it down to ~2.7V when on and 0 when off with a 22 µF cap as well per the suggestions in the datasheet for dealing with the impedance issues on A7.
However, when the device goes to sleep, there is additional resistance on A7 that drops the voltage divider such that it doesn't get about ~1.3V when mains is back on so it won't wake up. As soon as the reset button is pressed, this additional resistance goes away and it's all good.
Is there a known way around this? Or do I just need to switch to a small regulator to drop the 12-16V down to 3.3V and that should drive enough current to make A7 happy?
If you use RISING or FALLING for your interrupt, an internal pull is set on the pin before sleep.
If the wake is on CHANGE it does not apply pull, since it's unclear which direction to pull it. It's not exactly the same because it will behave differently if the pin is already in the interrupt state when going to sleep, but sometimes this can be a workaround.
But yes, a voltage regulator is a good option. We use the AP2204K for this purpose as it's inexpensive, tiny, and does not require an external inductor.