My application is only awake for two seconds out of every minute (3.3% of the time), but this is where it consumes 99% of its power, so I'd like to minimize power consumption when awake (currently 32 mA). Looking at the ESP32 technical reference manual, it looks like unused peripherals can, in principle, be disabled and/or have their clocks turned off. Is this possible to do in the Arduino IDE? I tried DPORT_PERI_CLK_EN_REG = 0, but the compiler doesn't recognize DPORT_PERI_CLK_EN_REG. Thanks for any tips.
Does including <soc/dport_reg.h> work?
Pieter
Thanks. At least the compiler no longer says it doesn't recognize it at all. Now it just doesn't recognize it as an lvalue:
error: lvalue required as left operand of assignment
According to the technical reference manual, the bits in the register are supposed to be settable:
5.3.7 Peripheral Clock Gating and Reset
Reset and clock gating registers covered in this section are active-high registers. Note that the reset bits are not
self-cleared by hardware. When a clock-gating register bit is set to 1, the corresponding clock is enabled. Setting
the register bit to 0 disables the clock. Setting a reset register bit to 1 puts the peripheral in a reset state, while
setting the register bit to 0 disables the reset state, thus enabling normal operation.
• DPORT_PERI_CLK_EN_REG: enables the hardware accelerator clock.
– BIT4, Digital Signature
– BIT3, Secure boot
– BIT2, RSA Accelerator
– BIT1, SHA Accelerator
– BIT0, AES Accelerator
Perhaps there's another way?
https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/system/sleep_modes.html
The ULP might be of interest to you.
I didn't think there was any way to program the ULP in Arduino.
Edit: Actually I just watched an Andres Spiess video in which he talks about how to do it, except you have to do it in assembler and the instruction set is very limited. It looks like it only draws 2 mA when running, but I'm not so desperate to get this working that I'm going to write SPI and I2C drivers in assembly, among other obstacles.