You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Play/WebSocket3Aqva/timer.ino

41 lines
1.2 KiB

void settimer() {
/* LED pin */
//int led = 14;
/* LED state */
//volatile byte state = LOW;
// Use 1st timer of 4 (counted from zero).
// Set 80 divider for prescaler (see ESP32 Technical Reference Manual for more
// info).
timer = timerBegin(2, 80, true);
/* Attach onTimer function to our timer */
// timerAttachInterrupt(timer, &onTimer, true);
timerAttachInterrupt(timer, &onTimer, true);
/* Set alarm to call onTimer function every second 1 tick is 1us
=> 1 second is 1000000us */
/* Repeat the alarm (third parameter) */
timerAlarmWrite(timer, 5000000, true);
/* Start an alarm */
timerAlarmEnable(timer);
// Serial.println("start timer");
}
void IRAM_ATTR onTimer()
{
EpochTime=EpochTime+5;
esp_task_wdt_reset();//reset WDT
//Serial.print("EpochTime=");
//Serial.println(EpochTime);
// Increment the counter and set the time of ISR
// portENTER_CRITICAL_ISR(&timerMux);
// isrCounter++;
// lastIsrAt = millis();
// portEXIT_CRITICAL_ISR(&timerMux);
// Give a semaphore that we can check in the loop
// xSemaphoreGiveFromISR(timerSemaphore, NULL);
// It is safe to use digitalRead/Write here if you want to toggle an output
}