ULP Button rising

makavity
Posts: 5
Joined: Mon Jun 15, 2020 1:59 am

ULP Button rising

Postby makavity » Mon Jun 15, 2020 2:07 am

Hello. Could not find any example of my trouble.
I have ESP32-Solo-1 with button, connected GND-BUTTON-GPIO2.
So, the problem, how to wakeup main processor with rising of GPIO2 from ULP?
Tried ~R0, !R0, no effect.
Falling works fine.

The code is:

Code: Select all

    rtc_gpio_init(GPIO_NUM_2);
    rtc_gpio_set_direction(GPIO_NUM_2, RTC_GPIO_MODE_INPUT_OUTPUT);

    rtc_gpio_set_level(GPIO_NUM_2, 1);
    rtc_gpio_pullup_en(GPIO_NUM_2);
    rtc_gpio_hold_en(GPIO_NUM_2);

Code: Select all

#define I_CLEAR_R() \
  I_MOVI(R0, 0), \
  I_MOVI(R1, 0), \
  I_MOVI(R2, 0), \
  I_MOVI(R3, 0)
  ...
              M_LABEL(15),
            I_CLEAR_R(),
            I_RD_REG(RTC_GPIO_IN_REG, RTCIO_GPIO2_CHANNEL + 14, RTCIO_GPIO2_CHANNEL + 14),
            I_ANDI(R0, R0, 1),
            I_MOVI(R0, ~R0),
            M_BL(10,1),
            
            M_LABEL(10),
            I_WAKE(),

boarchuz
Posts: 566
Joined: Tue Aug 21, 2018 5:28 am

Re: ULP Button rising

Postby boarchuz » Mon Jun 15, 2020 5:38 am

You can test for >=1 using M_BGE(label, 1). ie. Simply replace your M_BL(10, 1) with M_BGE(10, 1).

And remove I_MOVI(R0, ~R0).

And I strongly recommend disabling output if you're externally shorting this pin to ground via the button.

makavity
Posts: 5
Joined: Mon Jun 15, 2020 1:59 am

Re: ULP Button rising

Postby makavity » Mon Jun 15, 2020 8:23 am

Yeap, just tried it already, but, same, no effect.

chegewara
Posts: 2240
Joined: Wed Jun 14, 2017 9:00 pm

Re: ULP Button rising

Postby chegewara » Mon Jun 15, 2020 10:27 am

Why just dont use ext0/ext1 wakeup?

boarchuz
Posts: 566
Joined: Tue Aug 21, 2018 5:28 am

Re: ULP Button rising

Postby boarchuz » Mon Jun 15, 2020 11:01 am

Could you post your updated ULP program and pin config?

makavity
Posts: 5
Joined: Mon Jun 15, 2020 1:59 am

Re: ULP Button rising

Postby makavity » Fri Jun 26, 2020 1:55 pm

chegewara, bcs I can't use ext0 and ESP_SLEEP_WAKEUP_ULP.

Updated ULP code:

Code: Select all

I_CLEAR_R(),
I_RD_REG(RTC_GPIO_IN_REG, RTCIO_GPIO2_CHANNEL+14, RTCIO_GPIO2_CHANNEL+14),
M_BGE(10,1),

M_LABEL(10),
I_WAKE(),
And

Code: Select all

#define I_CLEAR_R() \
  I_MOVI(R0, 0), \
  I_MOVI(R1, 0), \
  I_MOVI(R2, 0), \
  I_MOVI(R3, 0)

boarchuz
Posts: 566
Joined: Tue Aug 21, 2018 5:28 am

Re: ULP Button rising

Postby boarchuz » Fri Jun 26, 2020 4:15 pm

Code: Select all

rtc_gpio_init(GPIO_NUM_2);
rtc_gpio_set_direction(GPIO_NUM_2, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pullup_en(GPIO_NUM_2);
rtc_gpio_pulldown_dis(GPIO_NUM_2); //2 has default pulldown
//Don't enable output
//Don't enable hold

Code: Select all

const ulp_insn_t program[] = {
  I_RD_REG(RTC_GPIO_IN_REG, RTCIO_GPIO2_CHANNEL+14, RTCIO_GPIO2_CHANNEL+14),
  //If pin is high, goto 10
  M_BGE(10,1),
      //Else it is low (ie. button is pushed). Wake.
      I_WAKE(),
      //Continue to halt
  M_LABEL(10),
  I_HALT(),
};

Who is online

Users browsing this forum: No registered users and 232 guests