
I'm very excited by Thomas Waldmann's MicroPython ULP assembler and I've been trying to use it because I want to program in Python but I need low power consumption while waiting for a trigger situation.
So, all I want to do is read the ADC and WAKE the main cores if certain values are found, but all that seems available is esp32.wake_on_touch(wake), esp32.wake_on_ext0(pin, level) and esp32.wake_on_ext1(pin, level), none of which suit my purpose. Can anyone tell me why there is not a esp32.wake_on_wake() function? It would seem the easiest of all!
Here us my ULP program:
data: .long 0
entry: move r3, data # load address of data into r3
move r2, 0 # initialise r2 to sum 4 results
adc r0, 0, 7 ## use adc on pin 34 into r1 Ch6 plus one
move r1, r2
add r2, r1, r0 # add in adc val in r1
adc r0, 0, 7 ## use adc on pin 34 into r1 Ch6 plus one
move r1, r2
add r2, r1, r0 # add in adc val in r1
adc r0, 0, 7 ## use adc on pin 34 into r1 Ch6 plus one
move r1, r2
add r2, r1, r0 # add in adc val in r1
adc r0, 0, 7 ## use adc on pin 34 into r1 Ch6 plus one
move r1, r2
add r2, r1, r0 # add in adc val in r1
rsh r2, r2, 0x02 # shift right twice to divide by 4
st r2, r3, 0 # store r2 contents into data ([r3+0]) to be picked up by MP
exit: HALT // Stop the ULP program
This just gets the average value over 4 samples from the ADC and stores it ready to be picked up by MP which is in deepsleep for 30 secs but I want to run the ULP in a loop (or on the ULP timer) and use a ulp WAKE instruction to return to MicroPython when required.
I have considered using IO pins to trigger WAKE, but so far the ulp REG_RD instruction to read RTCIO is unfathomable to me and Thomas doesn't yet support the macros that can be used for simple pin IO so, please, if anybody knows about any of this, please chime in!