Correct argument for ulp_run

iamflimflam1
Posts: 12
Joined: Fri May 22, 2020 7:58 am

Correct argument for ulp_run

Postby iamflimflam1 » Sun Oct 10, 2021 6:08 pm

I'm confused by what should be passed in the argument for

Code: Select all

ulp_run
I've seen examples that show this:

Code: Select all

ulp_run((&ulp_entry - RTC_SLOW_MEM)/4);
and this

Code: Select all

ulp_run(&ulp_entry - RTC_SLOW_MEM);
In the docs it does say that it should be expressed in 32 bit words - which I think is where the /4 is coming from in other examples.

Which is correct? Or doesn't it matter?

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

Re: Correct argument for ulp_run

Postby boarchuz » Mon Oct 11, 2021 4:50 pm

&ulp_entry and RTC_SLOW_MEM are both pointers to uint32_t, so the pointer arithmetic will take care of it.
eg. ((uint32_t*) 0x50000004) - ((uint32_t*) 0x50000000) = 1
Maybe in those other examples, &entry is uint8_t*?

As far as I know, the ULP program will always be built such that ulp_entry is at 0x50000000 (ie offset 0), so in practice it doesn't matter still gets the right result.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 92 guests