-->
Page 1 of 1

us level timing

PostPosted: Thu Nov 17, 2016 10:27 am
by viktak
Hi,
I was wondering if it is possible to generate timer events at less than a ms level. The
Code: Select allos_timer_arm
function takes milliseconds as a parameter. However, I want to check and record the state of an input every 50us or so.
I am using an ESP-12 board with PlatformIO.
Thanks for any pointers!

Re: us level timing

PostPosted: Thu Nov 17, 2016 12:12 pm
by Ribeiro Santos
Maybe something like that?



extern "C"{
#include "user_interface.h"
}

int delayMsg = 10000;
bool _timeout = true;
os_timer_t mTimer;

void tCallback(void *tCall){
_timeout = true;
}

void usrInit(void){
os_timer_setfn(&mTimer, tCallback, NULL);
os_timer_arm(&mTimer, delayMsg, true);
}

void setup() {
usrInit();
}

void loop() {

if (_timeout){

os_timer_disarm(&mTimer);

//do something... bla bla

_timeout = false;
os_timer_arm(&mTimer, delayMsg, true);
}

yield();
}