Need API support to provide micro seconds delay

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Need API support to provide micro seconds delay

Postby Ritesh » Tue Jun 20, 2017 5:48 pm

Hi,

As I have observed that vTaskDelay is working on Tick Rate which gives milliseconds delay for application development but I want to prove some microseconds delay in my application.

So is there any other API to provide that type of microseconds of delay?

Till Now, we have used ets_delay_us FreeRTOS API to get microseconds delay but that is not recommend to use.

So is there any other API to provide microseconds delay? We have 10 and 40 microseconds delay requirement for our application development purpose.

Let me know if anyone has any idea for that.
Regards,
Ritesh Prajapati

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Need API support to provide micro seconds delay

Postby kolban » Tue Jun 20, 2017 9:59 pm

You might want to take a look at gettimeofday(). Apparently (by reading the docs) it returns a time stamp down to the microsecond level. In principle, you could look around using gettimeofday until your interval has elapsed.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Need API support to provide micro seconds delay

Postby Ritesh » Wed Jun 21, 2017 12:56 am

kolban wrote:You might want to take a look at gettimeofday(). Apparently (by reading the docs) it returns a time stamp down to the microsecond level. In principle, you could look around using gettimeofday until your interval has elapsed.
Hi,

Thanks for quick reply.

But actually it will not work in my case as I need continues 10 and 40 microseconds delay for my application till some duration like 3 to 4 minutes as per requirement.

So, I have tried gettimeofday API with 2 consecutive calls and I was getting difference as 13 to 14 microseconds which was again not fixed. So that way it can not be used as I need accurate 10 and 40 microseconds delay for my application.

Hope you understand my concern.
Regards,
Ritesh Prajapati

ESP_Sprite
Posts: 9759
Joined: Thu Nov 26, 2015 4:08 am

Re: Need API support to provide micro seconds delay

Postby ESP_Sprite » Wed Jun 21, 2017 1:36 am

Can I ask what you are using this for? Are you trying to comfirm to some signalling spec or something? Asking because depending on the application, there may be more elegant (I2S, RMT, ...) ways to solve this.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Need API support to provide micro seconds delay

Postby Ritesh » Wed Jun 21, 2017 2:00 am

ESP_Sprite wrote:Can I ask what you are using this for? Are you trying to comfirm to some signalling spec or something? Asking because depending on the application, there may be more elegant (I2S, RMT, ...) ways to solve this.
Hi,

Actually, we have connected one module over UART with ESP32 chip in our product. So in that module, we need exact delay of 10 and 40 microseconds of delay interval in some interval to update firmware into that module using one wire communication over GPIO pins.

So, Normal communication with that module using ESP32 is UART but to upgrade firmware into that module we need to use one wire communication over GPIO pin toggling connected with ESP32.

That is why to toggle that GPIO with some particular interval, we need 10 and 40 microseconds of interval as per it's Firmware Update architecture.

Let me know if need any other information from my side.
Regards,
Ritesh Prajapati

ESP_Sprite
Posts: 9759
Joined: Thu Nov 26, 2015 4:08 am

Re: Need API support to provide micro seconds delay

Postby ESP_Sprite » Wed Jun 21, 2017 2:09 am

Isn't it easier to use the RMT peripheral then? That peripheral is designed to send user-shaped pulse trains with high precision.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Need API support to provide micro seconds delay

Postby Ritesh » Wed Jun 21, 2017 2:40 am

ESP_Sprite wrote:Isn't it easier to use the RMT peripheral then? That peripheral is designed to send user-shaped pulse trains with high precision.
Hi,

I need to check that RMT interface. Here, we have only one wire GPIO pin to update firmware into connected module.

Please share example of RMT based interface as per my requirements. I will check into ESP32 examples for that as well.
Regards,
Ritesh Prajapati

jakkubu
Posts: 4
Joined: Thu Mar 16, 2017 11:18 am

Re: Need API support to provide micro seconds delay

Postby jakkubu » Thu Jul 13, 2017 12:39 pm

Hi. Did you manage to get it work?

In Nodemcu for esp32 (currently in development stage) they implement OneWire interface for esp32 using RMT. I plan to use it for DS18B20 since I don't like the idea of using delays for communication protocols.

NodeMCU OneWire implementation for esp32 - https://github.com/nodemcu/nodemcu-firm ... /onewire.c

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Need API support to provide micro seconds delay

Postby Ritesh » Wed Aug 09, 2017 3:56 am

jakkubu wrote:Hi. Did you manage to get it work?

In Nodemcu for esp32 (currently in development stage) they implement OneWire interface for esp32 using RMT. I plan to use it for DS18B20 since I don't like the idea of using delays for communication protocols.

NodeMCU OneWire implementation for esp32 - https://github.com/nodemcu/nodemcu-firm ... /onewire.c
Hi,

Sorry for late reply.

Yes. We have ported that stuff using RMT Interface and it works fine without any issue.
Regards,
Ritesh Prajapati

kearins
Posts: 21
Joined: Sun Jul 23, 2017 11:48 pm

Re: Need API support to provide micro seconds delay

Postby kearins » Mon Aug 21, 2017 8:23 pm

Ritesh wrote: Yes. We have ported that stuff using RMT Interface and it works fine without any issue.
Hi, Ritech, could I put an eye on your ported version of onewire.c?

Who is online

Users browsing this forum: No registered users and 131 guests