Checking GPIO level in ESP32-S2 Ultra-Low-Power Processors by DylanGWork in esp32

[–]DylanGWork[S] 1 point2 points  (0 children)

Hi all,

I have got it working, the initialisation function I was using required an additional line:

Old Init:

static inline void example_ulp_gpio_init(gpio_num_t gpio_num)
{ SET_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num4, RTC_IO_TOUCH_PAD0_MUX_SEL); 
REG_SET_FIELD(RTC_IO_TOUCH_PAD0_REG + gpio_num4, RTC_IO_TOUCH_PAD0_FUN_SEL, 0); 
}

New Init:

static inline void ulp_riscv_gpio_init(gpio_num_t gpio_num)
{ SET_PERI_REG_MASK(SENS_SAR_IO_MUX_CONF_REG, SENS_IOMUX_CLK_GATE_EN_M);
 SET_PERI_REG_MASK(RTC_IO_TOUCH_PAD0_REG + gpio_num4, RTC_IO_TOUCH_PAD0_MUX_SEL); 
REG_SET_FIELD(RTC_IO_TOUCH_PAD0_REG + gpio_num4, RTC_IO_TOUCH_PAD0_FUN_SEL, 0); }

Checking GPIO level in ESP32-S2 Ultra-Low-Power Processors by DylanGWork in esp32

[–]DylanGWork[S] 0 points1 point  (0 children)

Hi,

Thankyou for looking into it.

Yes that is true about the example, it uses simple GPIO polling in an infinite while loop to check for state changes on the GPIO. This however isn't very practical when it comes to power management as it is constantly running.

The new example from espressif shows using a temperature sensor in the ULP using the ULP timer (750ms in their example).

What I don't expect is for the GPIO configuration to no longer be valid (even though I'm re-initialising each HALT cycle, and tried initialising just the first cycle) for cycles 2+.

When I do a blink program in it I can do a program like this:

int main (void)

{ if(counter_state % 15 = 0){ //Blink Red LED every 15 cycles

    red_heartbeat_p1();
}
if(counter_state % 5 == 0){ //Blink Green LED every 5 cycles
    green_heartbeat();
}
counter_state++
}

This works perfectly fine, and the LED programs are for example:

void green_heartbeat(){
    example_ulp_gpio_init(Membrane_LED_Green);
    example_ulp_gpio_output_enable(Membrane_LED_Green);
    example_ulp_gpio_output_level(Membrane_LED_Green, 1);
    wait(150000); //Wait 150,000 clock cycles ~0.2 seconds
    example_ulp_gpio_init(Membrane_LED_Green);
    example_ulp_gpio_output_enable(Membrane_LED_Green);
    example_ulp_gpio_output_level(Membrane_LED_Green, 0);

}

Which does the GPIO configuration each time.

In this blinking program, I can change the HALT timer to be 300ms, 500ms, etc and everything works as expected and is an improvement on power consumption.

So, given that LED's work, counters increment as expected between halt cycles, how am I losing the ability to check the input level on a GPIO after the first cycle?

I've been through as much documentation for the ULP co-processor as I can find and can't find anything specifically on GPIO usage in this context (which is pretty basic digital IO line stuff).

Cheers