求助!如何在ESP32上获得一个微妙级延时

lqzero
Posts: 10
Joined: Mon Jul 22, 2019 2:22 am

求助!如何在ESP32上获得一个微妙级延时

Postby lqzero » Mon Jul 22, 2019 9:44 am

RT

jiangteng
Posts: 12
Joined: Wed Jan 30, 2019 7:08 am

Re: 求助!如何在ESP32上获得一个微妙级延时

Postby jiangteng » Tue Aug 06, 2019 5:56 am

  1. #include "sys/unistd.h"
  2. //....
  3. usleep(1000);
  4. //....

ESP_Dazz
Posts: 143
Joined: Fri Jun 02, 2017 6:50 am

Re: 求助!如何在ESP32上获得一个微妙级延时

Postby ESP_Dazz » Tue Aug 06, 2019 6:09 am

其实usleep()底层会调用ets_delay_us(),可以考虑直接用ets_delay_us()
  1. #include "esp32/rom/ets_sys.h"
  2. ...
  3. ets_delay_us(1000);

lqzero
Posts: 10
Joined: Mon Jul 22, 2019 2:22 am

Re: 求助!如何在ESP32上获得一个微妙级延时

Postby lqzero » Tue Aug 06, 2019 9:17 am

两个函数都试过啦 ,都不是很准,自己用定时器搞定啦。谢谢两位

assinass
Posts: 1
Joined: Thu Aug 22, 2019 7:52 am

Re: 求助!如何在ESP32上获得一个微妙级延时

Postby assinass » Thu Aug 22, 2019 7:57 am

;) 用用这个如何,延时100us:

Code: Select all

#include "freertos/FreeRTOS.h"

vTaskDelay(100 / portTICK_PERIOD_MS);

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 24 guests