Esp32-S3 : VERY IMPORTANT ! Use of the ULP Copro in order to receive or send datas on a Pin synchronously.

ThomasESP32
Posts: 191
Joined: Thu Jul 14, 2022 5:15 am

Esp32-S3 : VERY IMPORTANT ! Use of the ULP Copro in order to receive or send datas on a Pin synchronously.

Postby ThomasESP32 » Thu Mar 30, 2023 8:19 am

Good afternoon,

I am using an Esp32-S3 microcontroller and I need to implement the following feature :

"An external component provides a 4000Hz Clk (250uS period) on a CLK_PIN of the Esp32-S3 and depending
on its mode, the Esp32-S3 must have the possibility to send or receive datas on/from a a DATA_PIN (On CLK_PIN edges).
The Esp32-S3 behaviour must be the following :
1) In RxMode : The Esp32-S3 must receive datas from the DATA_PIN when the CLK_PIN goes High.
2) In TxMode : The Esp32-S3 must send datas on the DATA_PIN when the CLK_PIN goes Low."

This is typically what a SPI Receiver can do. However, I have no free SPI in my application.
I am looking for another way to implement this function.
Because the Clock period is very low (250 us), I don't want to do this using interrupts on the CLK_PIN of the Esp32-S3
(Because this would disturb the behaviour of my application too much).

I have seen in the reference manual that an ULP-RISC-V ULP Coprocessor exists in the chip.
Do you think that this function could be realized by this coprocessor and how ?

I have few questions concerning the ULP-RISC-V ULP Coprocessor :
1) Is it possible to exchange info between the CPU0 or CPU1 (Main_Appli) and the ULP Copro so that the Copro can know
that the "Main_Appli" is in RxMode or TxMode ?
2) Can the Copro be configured to generate an interrupt on the CLK_PIN with a 250us period ?
3) If yes, I have seen that interrupts can only be level interrupts and not edge interrupts. Do you think that using level interrupts on
the CLK_PIN, I can implement the following feature ?
4) If yes, do you think it is possible to change the level on the interrupt (LOW or HIGH) depending on the main appli (On CPU0 and CPU1 side) mode (Rx/Tx).
5) Do you think it is possible to record the samples that are on the DATA_PIN in RxMode and put some samples on the DATA_PIN in TxMode in the CLK_PIN interrupt handler ?

I see that the ULP-RISC-V ULP Coprocessor has a Monitor mode. I wish I could use this mode in order to implement the feature. However, I also see that there are HALT and RUN periods in this mode. So :
1) Can the Copro deal with interrupts in HALT Mode or only in RUN Mode ?
2) If the answer is No, is it possible to always put the Copro into RUN Mode ? Or is it possible to set the HALT Mode very short ?

Another question, the goal in RxMode is to detect a special pattern on the DATA_PIN.
If the pattern is detected on the Copro side (Using the above principle), is it possible to send a signal or to set a variable
on the main_application (Running on CPU0 and CPU1 side ?).

Thank you for your help on the subject.
This is really important.

Best regards,

Thomas TRUILHE

ThomasESP32
Posts: 191
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32-S3 : VERY IMPORTANT ! Use of the ULP Copro in order to receive or send datas on a Pin synchronously.

Postby ThomasESP32 » Thu Mar 30, 2023 8:26 am

I would like to say "I have seen that a Normal Mode exists in the ULP Copro" instead of "I have seen that a Monitor Mode exists in the ULP Copro" sorry.

ThomasESP32
Posts: 191
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32-S3 : VERY IMPORTANT ! Use of the ULP Copro in order to receive or send datas on a Pin synchronously.

Postby ThomasESP32 » Thu Mar 30, 2023 8:32 am

Maybe I have misunderstood something...
Do you think that in normal mode, the ULP Copro is always running and there is no HALT and RUN periods ?

a2800276
Posts: 74
Joined: Sat Jan 23, 2016 1:59 pm

Re: Esp32-S3 : VERY IMPORTANT ! Use of the ULP Copro in order to receive or send datas on a Pin synchronously.

Postby a2800276 » Thu Mar 30, 2023 12:56 pm

My understanding is that the ULP does not support the SPI peripheral, at least not via an API.
I doubt that it would be able to access the SPI peripherals via memory mapped IO, but even if it could, you said all the SPI's are already in use.
This would mean that you would need to bitbang SPI.
If you're bit-banging SPI anyway, why no just do it on the main, fast processor than the one optimized for ultra low power consumption?

> 1) Is it possible to exchange info between the CPU0 or CPU1 (Main_Appli) and the ULP Copro so that the Copro can know
> that the "Main_Appli" is in RxMode or TxMode ?

Yes, it's a bit involved because you have to define common variables in the linker script, I believe. The IDF documentationhttps://docs.espressif.com/projects/esp ... isc-v.html has some details you may want to familiarize yourself with.

> 2) 3) 4) Interrupt questions ...

I'm a little confused by your elaboration: why would you want to generate interrupts from the ULP when the clock pin changes? Why not just use the ESP's native interrupts?

I think you may be mistaken about the general purpose of the ULP. It's not a "coprocessor" in the sense that it's a third core to offload work onto. It's meant to perform minimal processing/monitoring tasks while the main cores are sleeping.

Minor Nitpick: Your title would be improved if you omit the "VERY IMPORTANT!". Apart from the all caps being annoying, it doesn't add much value, because, well, this is very important only to you :)

ThomasESP32
Posts: 191
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32-S3 : VERY IMPORTANT ! Use of the ULP Copro in order to receive or send datas on a Pin synchronously.

Postby ThomasESP32 » Fri Mar 31, 2023 6:48 am

Thank you for your answer.
So you mean that it is not possible to use the RISC-V ULP Copro as an extra code and do
processing while the other cores are running ? Even in normal mode ?

Best regards,

Thomas TRUILHE

a2800276
Posts: 74
Joined: Sat Jan 23, 2016 1:59 pm

Re: Esp32-S3 : VERY IMPORTANT ! Use of the ULP Copro in order to receive or send datas on a Pin synchronously.

Postby a2800276 » Fri Mar 31, 2023 12:17 pm

So you mean that it is not possible to use the RISC-V ULP Copro as an extra code and do
processing while the other cores are running ? Even in normal mode ?
No I mean the ULP is not a third core for additional processing power or more IO peripherals. It's a minimal subsystem intended to allow selected (trivial) tasks to be executed while the main cores sleep.

If you look at the documentation I linked to, there does not seem to be any indication that both core types can't be running simultaneously. It just wouldn't make sense to run them simultaneously because anything that can be done on the ULP can be achieved easier and more efficiently on the application cores.

ThomasESP32
Posts: 191
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32-S3 : VERY IMPORTANT ! Use of the ULP Copro in order to receive or send datas on a Pin synchronously.

Postby ThomasESP32 » Sat Apr 01, 2023 12:00 pm

Ok,
but here, my idea was to do interrupt on input PIN using the ULP Copro instead of doing this on the CPU0 or 1.

Of course the CPU0 or 1 can do interrupt function but this would disturb the processes running on my program.
So I just would like to do interrupt process on the ULP Copro while the CPU0 and 1 are running.

Do you think it is possible and how ?

Best regards

MicroController
Posts: 1118
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Esp32-S3 : VERY IMPORTANT ! Use of the ULP Copro in order to receive or send datas on a Pin synchronously.

Postby MicroController » Sat Apr 01, 2023 3:01 pm

This should definitely be possible. Even the FSM-ULP could do it; polling for a clock edge and then either read a bit from IO or write a bit to IO and send one interrupt to the main CPU after n (8? 16? 32?) bits have been transferred.
Not too far away from https://github.com/espressif/esp-idf/tr ... lp_fsm/ulp

ThomasESP32
Posts: 191
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32-S3 : VERY IMPORTANT ! Use of the ULP Copro in order to receive or send datas on a Pin synchronously.

Postby ThomasESP32 » Sat Apr 01, 2023 3:33 pm

Very good news !!!
I would like to try it on the RISC-V Coprocessor.

Do you know how to write program on this ULP copro ?
Are there examples or something like that ??

Best regards,


Who is online

Users browsing this forum: No registered users and 82 guests