Page 1 of 1

Timer management with and without interrupt

Posted: Wed Jun 29, 2016 2:55 pm
by bluebird
Hi,

I need to set high a GPIO (digital out) for 25 microseconds and then put it down for 975 microseconds. It is microseconds and not milliseconds.

Could you give a example of code in (RTOS) C for ESP32 using the right lib?
I saw the blinky example, but it's based on milliseconds, and on callback functions for os_timer functions. Should we use "delay()" as we don't want the 25 microseconds :( to be interrupted. The 975 microseconds can be interrupted ;) .

Thanks in advance,

Re: Timer management with and without interrupt

Posted: Thu Jun 30, 2016 3:45 am
by ESP_Sprite
What is the specific purpose of this? Do you need this single-shot or do you need to generate a continuous stream with these values? Either way, I think you may be best served by a peripheral; either the LED PWM generator or the RMT peripheral: they can both generate these signals independently of any interrupts.

Re: Timer management with and without interrupt

Posted: Fri Jul 01, 2016 11:31 pm
by bluebird
Hi Sprite_tm,

That will be streams of those logical high signals to control an Infra-red LED. I need microseconds level of high level.
PWM won't do the effect as the low state following the high logical state is very very long compared to 40 microseconds of high state.

Does "delay()" function work? Who can I make it in microseconds?

Cheers,

Re: Timer management with and without interrupt

Posted: Tue Jul 05, 2016 10:43 am
by ESP_Sprite
Hmm, we actually have a dedicated peripheral for exactly that purpose (the RMT peripheral). Unfortunately, there's not really any example code or documentation public for that... if you can wait until the ESP32 documentation is out, you can solve the problem in a really nice way.

You can try the esp_delay_us() function, but it will be imprecise because of interrupts etc; maybe it's good enough for this purpose.