ULP Instruction set passing value with global variables

costa-victor
Posts: 1
Joined: Sat Apr 02, 2022 11:21 am

ULP Instruction set passing value with global variables

Postby costa-victor » Sat Apr 02, 2022 11:59 am

Hello there, I'm trying to enable some GPIO's using the ULP while the main processor are in deep sleep mode.

I accomplish this without problems using the ULP examples and enabling the RTC_GPIO_OUT_REG register. Just like the code below:
  1. // Enable RTC GPIO 12, which is equivalent to GPIO2
  2. WRITE_RTC_REG(RTC_GPIO_OUT, REG, RTC_GPIO_OUT_DATA_S+12, 1, 1)
However, I couldn't enable the RTC GPIO 12 using a variable passed by the main processor. The code below shows the instructions that works and what didn't work and I would like to do.
  1. .set gpio_num, 12    // Create a constant with constains the value 12
  2.  
  3. .bss
  4.  
  5. // Create a variable gpio_var and add the value 12 from the main code as showed in the ULP Example
  6. .global gpio_var
  7. gpio_var: .long 0
  8.  
  9.  
  10. // This instruction using a constant works! Because I am passing the value and not the address
  11. WRITE_RTC_REG(RTC_GPIO_OUT, REG, RTC_GPIO_OUT_DATA_S+gpio_num, 1, 1)
  12.  
  13. // This instruction cause an compilation error, probably because I a, passing the address instead the value
  14. WRITE_RTC_REG(RTC_GPIO_OUT, REG, RTC_GPIO_OUT_DATA_S+gpio_var, 1, 1)
So, how could I use here a global variable with the GPIO value I want to activate?

Thanks,
Victor

Who is online

Users browsing this forum: Bing [Bot], Usama Masood and 104 guests