Page 1 of 1

ULP General Purpose Registers R4-R7

Posted: Mon May 13, 2019 3:55 am
by boarchuz
The ULP CP instruction set says "ULP coprocessor has 4 16-bit general purpose registers, labeled R0, R1, R2, R3".
I'm currently using the macros to program it, and only R0-R3 are defined here: https://github.com/espressif/esp-idf/bl ... /ulp.h#L35

Yet, looking through the registers, there also exists R4-R7 here: https://github.com/espressif/esp-idf/bl ... eg.h#L1801
I just tested these in a program by simply defining them as 4-7 and replacing R1-R3 with R4-R7 respectively, and everything seems to be working fine.

So, naturally, I'm curious why these aren't documented or used. Are they safe to use? Is it as simple as the method I described above, or was that just a coincidence?

Re: ULP General Purpose Registers R4-R7

Posted: Mon May 13, 2019 4:32 am
by ESP_Sprite
Those are scratch registers for the RTC peripheral, not CPU registers for the ULP. As the macros you use are very simple and don't have any real sanity checks in them, they will accept R4-R7 but they will generate non-working code as these registers do not exist and even if they did, the ISA has no way of addressing them.

Re: ULP General Purpose Registers R4-R7

Posted: Tue May 14, 2019 4:49 am
by boarchuz
Thanks, Sprite, that makes sense.
It seems to have worked for a while... Then I returned later to find the board non-functional as a MOSFET had died, so not a good idea to play with those registers :lol:

I think the macros aren't really supported but I'll add here that it would be great to have the 8-bit stage counter available too. It seems about the only thing missing from the set of macros since the commands commented as "not implemented yet" actually are in my experience.