ULP global variables

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

ULP global variables

Postby urbanze » Tue Oct 03, 2017 7:38 pm

Hi guys! I tried to change any global variable with ULP, but doesnt work. What I do wrong?
(The code simply read the variable before, and after the ULP to check if the variable has changed.)

C code

Image


Assembly code
Image

User avatar
ESP_krzychb
Posts: 400
Joined: Sat Oct 01, 2016 9:05 am
Contact:

Re: ULP global variables

Postby ESP_krzychb » Tue Oct 03, 2017 8:35 pm

Hi urbanze,
urbanze wrote:I tried to change any global variable with ULP, but doesnt work. What I do wrong?
I can't read anything on these screen shoots :shock: I will be guessing then :D

Maybe you are missing the "ulp_" prefix?
Ref. https://esp-idf.readthedocs.io/en/lates ... -variables

EDIT: If this is not the case, then try a classic example https://github.com/espressif/esp-idf/tr ... system/ulp.
This example is using global variables and it works for me.

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: ULP global variables

Postby urbanze » Wed Oct 04, 2017 1:43 am

krzychb wrote:Hi urbanze,
urbanze wrote:I tried to change any global variable with ULP, but doesnt work. What I do wrong?
I can't read anything on these screen shoots :shock: I will be guessing then :D

Maybe you are missing the "ulp_" prefix?
Ref. https://esp-idf.readthedocs.io/en/lates ... -variables

EDIT: If this is not the case, then try a classic example https://github.com/espressif/esp-idf/tr ... system/ulp.
This example is using global variables and it works for me.
Thanks for reply krz!. I know about "ulp_" variables, and yes, I using this and doenst work... I think is anything about load or store, but need help...


Why you cant view screen shots?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: ULP global variables

Postby ESP_igrr » Wed Oct 04, 2017 3:12 am

ULP code seems to be missing a store after the increment.

User avatar
ESP_krzychb
Posts: 400
Joined: Sat Oct 01, 2016 9:05 am
Contact:

Re: ULP global variables

Postby ESP_krzychb » Wed Oct 04, 2017 6:12 am

krzychb wrote:Why you cant view screen shots?
I can view the screen shots but not the tiny font :)
Copy and paste of code would work better for me in this case.
Also a plan text is easier for anybody to copy back for testing instead of retyping.

@ESP_igrr, thank you for help with this one!

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: ULP global variables

Postby urbanze » Wed Oct 04, 2017 6:16 am

ESP_igrr wrote:ULP code seems to be missing a store after the increment.
.global x
x: .long 0

.global entry
entry:

move r0, x
ld r0, r0, 0
add r0, r0, 1
st r0, r0, 0
halt

//or this

move r0, x
move r2, 10
ld r0, r0, 0
st r2, r0, 0
halt


Anyone doenst work, how can I do this simples process?¿

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: ULP global variables

Postby urbanze » Wed Oct 04, 2017 6:21 am

krzychb wrote:
krzychb wrote:Why you cant view screen shots?
I can view the screen shots but not the tiny font :)
Copy and paste of code would work better for me in this case.
Also a plan text is easier for anybody to copy back for testing instead of retyping.

@ESP_igrr, thank you for help with this one!

Code in C have:

variable: extern uint32_t ulp_x = 1;

and load/run to ulp.


Code in ulp

.global x
x: .long 0

.global entry
entry:

move r0, x
ld r0, r0, x
add r0, r0, 1
halt


I comment before with another two tests, and anyone doenst worked

User avatar
ESP_krzychb
Posts: 400
Joined: Sat Oct 01, 2016 9:05 am
Contact:

Re: ULP global variables

Postby ESP_krzychb » Wed Oct 04, 2017 6:41 am

urbanze wrote:Code in C have:

variable: extern uint32_t ulp_x = 1;

and load/run to ulp.
How do verify whether "ulp_x" is changing its value or not?

tomtor
Posts: 22
Joined: Thu May 11, 2017 6:15 am

Re: ULP global variables

Postby tomtor » Wed Oct 04, 2017 8:56 am

urbanze wrote:
Code in ulp

.global x
x: .long 0

.global entry
entry:

move r0, x
ld r0, r0, x
add r0, r0, 1
halt


I comment before with another two tests, and anyone doenst worked
Should be e.g.:

.global x
x: .long 0

.global entry
entry:

move r1, x // load address of x in r1
ld r0, r1, 0 // load data from x in r0
add r0, r0, 1 // increment r0
st r0,r1,0 // store r0 as new content of x
halt

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: ULP global variables

Postby urbanze » Wed Oct 04, 2017 12:39 pm

krzychb wrote:
urbanze wrote:Code in C have:

variable: extern uint32_t ulp_x = 1;

and load/run to ulp.
How do verify whether "ulp_x" is changing its value or not?

Code: Select all

void ulp()
{
	Serial.printf("\nULP_X: %d", ulp_x & UINT16_MAX);
	delay(100);
	ulp_load_binary(0, ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t));
	ulp_run((&ulp_entry - RTC_SLOW_MEM) / sizeof(uint32_t));
	delay(100);
	Serial.printf("\nULP_X: %d", ulp_x & UINT16_MAX);
}

Who is online

Users browsing this forum: FX2032, MicroController and 89 guests