Page 1 of 1

usleep as WAIT equivalent on RISC-V ULP

Posted: Tue Jan 26, 2021 6:09 pm
by andymule
Spent way too long trying to find this info, so here it is for others:

I wanted to wait a certain number of cycles/microseconds so I could do SPI from the RISC-V ULP on my ESP32-S2

Code: Select all

#include <unistd.h>
unsigned int microsecond = 1000000;
usleep(3 * microsecond);//sleeps for 3 second
I'm having a hard time finding good documentation about availability of commands such as this, would love to see this page expanded:
https://docs.espressif.com/projects/esp ... isc-v.html

Re: usleep as WAIT equivalent on RISC-V ULP

Posted: Wed Jan 27, 2021 4:15 am
by andymule
This didn't actually work, I'm sorry.

I also tried some clever C assembly calling from RISC like

Code: Select all

asm("wait 3");
And that also didn't work

I'm currently using this stupid function to wait a present amount of cycles based on the FSM docs cycles per functions:

Code: Select all

void wait2(int cycles)
{
    while (cycles > 0)
    {
        cycles -= 16; // since compiles to 16 cycles per iteration ??
    }
}
I'm unable to test this timing at the moment and am certainly looking for more input.

Re: usleep as WAIT equivalent on RISC-V ULP

Posted: Sun May 16, 2021 12:56 am
by deandob
Is there any more information on programming the S2 RISC-V ULP, as Andy mentioned in this thread the IDF documentation isn't helpful to understand how to use the ULP, some examples of common functions would be useful.

Or do we just assume its exactly the same as the non S2 ULP?

Thanks for the help.