usleep as WAIT equivalent on RISC-V ULP

andymule
Posts: 3
Joined: Tue Jan 26, 2021 5:50 pm

usleep as WAIT equivalent on RISC-V ULP

Postby andymule » Tue Jan 26, 2021 6:09 pm

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

andymule
Posts: 3
Joined: Tue Jan 26, 2021 5:50 pm

Re: usleep as WAIT equivalent on RISC-V ULP

Postby andymule » Wed Jan 27, 2021 4:15 am

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.

deandob
Posts: 22
Joined: Sun Dec 02, 2018 5:21 am

Re: usleep as WAIT equivalent on RISC-V ULP

Postby deandob » Sun May 16, 2021 12:56 am

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.

Who is online

Users browsing this forum: Bing [Bot], nopnop2002 and 152 guests