Timer management with and without interrupt

bluebird
Posts: 6
Joined: Thu Feb 04, 2016 1:16 pm

Timer management with and without interrupt

Postby bluebird » Wed Jun 29, 2016 2:55 pm

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,

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

Re: Timer management with and without interrupt

Postby ESP_Sprite » Thu Jun 30, 2016 3:45 am

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.

bluebird
Posts: 6
Joined: Thu Feb 04, 2016 1:16 pm

Re: Timer management with and without interrupt

Postby bluebird » Fri Jul 01, 2016 11:31 pm

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,

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

Re: Timer management with and without interrupt

Postby ESP_Sprite » Tue Jul 05, 2016 10:43 am

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.

Who is online

Users browsing this forum: Bing [Bot], GooseGoose, jesper and 67 guests