This is the code for timer example in esp8266..(got from a website)

My doubt is where the function timer1_enable(TIM_DIV16, TIM_EDGE, TIM_SINGLE) is defined ?? I am look in Ticker.cpp, but not found.

#include < ESP8266WiFi.h>
#include < Ticker.h >

Ticker blinker;

#define LED 2  //On board LED

void ICACHE_RAM_ATTR onTimerISR(){
    digitalWrite(LED,!(digitalRead(LED)));  //Toggle LED Pin

void setup()


    //Initialize Ticker every 0.5s
    timer1_enable(TIM_DIV16, TIM_EDGE, TIM_SINGLE);
    timer1_write(600000); //120000 us

void loop()
  • Found your example code here. Please always provide a link, when you ask questions about a code from the web. – chrisl Apr 23 '19 at 8:38
  • Also note that in C++, trivial functions are sometimes fully implemented in the .h file, so a search of the .cpp file might not reveal any code. This is especially common for access functions ("setters" and "getters"), where a function definition takes no more space (or very little more) than a declaration would. – JRobert Jun 22 '19 at 22:33

Those functions have nothing to do with the Ticker library. Those functions are defined in the ESP8266 core.

The example you cite has this at the top of it:

Hardware Timer0 is used by WiFi Functions. We can use only Timer1. Use of timer instead of Ticker gives advantage of precision timing and You can get timer interrupt in micro seconds.

Note the use of "instead of Ticker" there. That says that the code below has nothing to do with Ticker.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.