Post topics, source code that relate to the Arduino Platform

User avatar
By viktak
#58257 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!
User avatar
By Ribeiro Santos
#58262 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();
}