Comments (9)
@pguyot What I discovered by experiment is that with the original code for the M5StickC-Plus the processor wakes up in download mode when the power switch is pushed. After that it requires a power cycle to startup properly but setting bit 2 of register 0x90 fixes that, at least on the units that I have.
If you replace the last line in my SetSleep() function above with the line shown below the processor stays powered and can then be put into deep sleep and therefore be woken up with an interrupt (for example from the M5 button which is what I was looking for).
Write1Byte(0x12, Read8bit(0x12) & 0xA1); // Disable all outputs but DCDC1
from m5stickc-plus.
Yeah, there's something wrong with it: I was trying to wake the ESP with the motion-detection interrupt from the IMU but SetSleep prevented that. The old stickc version of the function instead works.
Bit-shift and bitwise operators are a bit too "low-level" for my poor little brain to understand fully what's going on here but, if I had to guess, I would say that some hardware changes (maybe adding the buzzer) also changed the addresses of on-board perifericals and forced them to update the function that now turns off something it shouldn't.
from m5stickc-plus.
The code from the original M5stick-C appears to work at first glance but it is leaving the processor running. On the other hand the M5stick-C plus code turns everything off but when the power switch is pressed it starts up waiting to download instead of a hard reset to startup properly. Using the datasheet for the AXP192 and Google Translate I discovered that the outputs during sleep had been changed to open collector (from floating) but changing it back to floating didn't work either. After some experimenting I found that the "low noise" setting seems to work reliably.
Here is my local function that does the job:
void SetSleep(void) //version M5stick-C plus
{
Write1Byte(0x31, Read8bit(0x31) | ( 1 << 3)); // short press to wake up
Write1Byte(0x90, Read8bit(0x90) | 0x02); // GPIO1 "low noise" otherwise it goes to download mode when waking up
Write1Byte( 0x12 , 0x00 ); // all outputs off
}
and local read and write functions to go with it:
uint8_t Read8bit( uint8_t Addr )
{
Wire1.beginTransmission(0x34);
Wire1.write(Addr);
Wire1.endTransmission();
Wire1.requestFrom(0x34, 1);
return Wire1.read();
}
void Write1Byte( uint8_t Addr , uint8_t Data )
{
Wire1.beginTransmission(0x34);
Wire1.write(Addr);
Wire1.write(Data);
Wire1.endTransmission();
}
The datasheet is here: http://www.x-powers.com/en.php/Info/down/id/50
EDIT - it probably would be better to leave the processor powered by the AXP192 and then put the ESP32 itself in deep sleep. That way it could wake up from interrupts. I may try this as I wan't to be able to wake the system up by pushing the main button.
from m5stickc-plus.
M5StickCPlus SetSleep version obviously doesn't work. The fact that it writes register 12H twice is suspect.
AXP192 drive code from M5StickC seems more recent and is better documented, and this version of SetSleep function actually works as @patjazz found.
From what I understand, writing 0x02 to register 0x90 effectively sets pin 19 to LDOio0 (instead of GPIO0), which is used for microphone on both M5StickC and M5StickCPlus. It is done in AXP192::begin() function of both drivers. Writing 0x07 to this register is done in the M5StickC driver elsewhere to effectively disable LD0. @RocketManRC where did you read anything related to setting the device in download mode?
from m5stickc-plus.
Hi guys
I concur in that the current AXP192::SetSleep()
function is not working as expected in regard of using deep sleep (or light sleep) functionality of ESP32. For deep sleep (or light sleep) to work, the ESP32 chip needs to stay powered on which can be achieved, as pointed out by @RocketManRC, by keeping DCDC1 on.
In my opinion the AXP192::SetSleep()
function should be restored to something similar as used for M5StickC and do the necessary preparation work for ESP32 deep sleep / light sleep so that AXP192::DeepSleep()
and AXP192::LightSleep()
functions can work properly.
And for the case where the system needs to be fully shut down the AXP192::PowerOff()
function should be reinstated.
Update: I don't think below line is doing what the comment is implicating. According to the datasheet register 0x31 deals with power off voltage and (1 << 3) which equals to bit 3 is reserved in that register. I think below line actually does nothing.
Write1Byte(0x31, Read8bit(0x31) | ( 1 << 3)); // short press to wake up
Thanks
Felix
from m5stickc-plus.
Hi guys
Re download mode: The reason, I think, that the setting for AXP GPIO0 matters when ESP32 is powered on is the fact that AXP GPIO0 (when set as LDO) powers the microphone. And the CLK input of the microphone is connected to GPIO0 of the ESP32 and ESP32 GPIO0 is a strapping pin which is used to determine whether to boot normally (ESP GPIO0 high) or into download mode (ESP32 GPIO0 low). It looks like when the microphone is not powered that its CLK input pulls down the line enough for it to register as low and hence forces the ESP32 into download mode.
Update: I ran a test on my M5StickCPlus with AXP GPIO0 set to floating (reg 0x90 set to 0x07) and after ESP32 deep sleep the device restarted in normal (not download) mode just fine. Checking the M5StickCPlus schematic there is a 1k pull-up resistor on ESP32 GPIO0 which should enforce normal startup.
Thanks
Felix
from m5stickc-plus.
By using the following commands, I get 2.09mA with Grove enabled:
Write1Byte(0x31 , Read8bit(0x31) | ( 1 << 3)); // Turn on short press to wake up
Write1Byte(0x90 , Read8bit(0x90) | 0x07); // GPIO1 floating
Write1Byte(0x82, 0x00); // Disable ADCs
Write1Byte(0x12, Read8bit(0x12) & ~(1<<1) & ~(1<<2) & ~(1<<3)); // Disable all outputs but DCDC1 (DCDC3 = NC, LDO2 = LCD-BL, LDO3 = LCD-Logic)
With Grove disabled (so the AXP disables the 5V step up converter for the Grove-VCC) I get 1.96mA
//Enables/Disables the 5V Boost for Grove
void AXP192::setGrovePower(bool active){
if(active){
Write1Byte(0x10, Read8bit(0x10) | (1<<2));
}else{
Write1Byte(0x10, Read8bit(0x10) &~(1<<2));
}
}
from m5stickc-plus.
Update: I don't think below line is doing what the comment is implicating. According to the datasheet register 0x31 deals with power off voltage and (1 << 3) which equals to bit 3 is reserved in that register. I think below line actually does nothing.
Write1Byte(0x31, Read8bit(0x31) | ( 1 << 3)); // short press to wake up
In Datasheet v1.13
, bit 3 is actually documented. A translation of this datasheet is available here:
https://github.com/rogerdahl/m5stickc-idf/blob/master/docs/AXP192%20Datasheet%20v1.13_cn.zh-CN.en.pdf
from m5stickc-plus.
This workaround works for me:
Write1Byte(0x12, Read8bit(0x12) & 0xA1); // Disable all outputs but DCDC1
But maybe in the new unified library from M5Stack they fixed the issue? Maybe not for this:
https://github.com/m5stack/M5Unified/blob/master/src/utility/Power_Class.cpp#L369-L377
But the workaround works. Maybe @RocketManRC should be do a pull request to them in this library?
from m5stickc-plus.
Related Issues (20)
- Issues about led and ir transmitter HOT 3
- ESP IDF mapping of screen PINs HOT 1
- Esp-idf arduino component require HOT 4
- Cannot connect Wifi on Arduino Idle HOT 1
- Get battery level execution issue HOT 2
- M5Display::setBrightness will it be implemented ? HOT 3
- Free_Fonts.h missing HOT 1
- Cant Change CPU speed HOT 1
- RTC.ccp has error: 2nd "GetDate(" needs changing to "SetDate(" HOT 1
- How can we calibrate the IMU gyros?
- Wont compile HOT 6
- Broken link from M5StickC 8-Channel Servo Driver HAT doc HOT 2
- C_BACK_DRIVER.ino is wildly incomplete for a commercial example
- {Update} Can I suggest an update the to I2C tester.ino
- Infrared not functioning HOT 1
- Wrong IMU pins HOT 3
- If (Serial) always returns true HOT 3
- Black display when using setcursor() even when changing fontsizes from 1 to 7 HOT 3
- M5StickCPlus example compile error HOT 3
- Can't compile the examples, not even Hello World HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from m5stickc-plus.