#define RED_LED     21
#define GREEN_LED   19

hw_timer_t *Red_timer = NULL;
hw_timer_t *Green_timer = NULL;


// This is the Timer ISR. It is automatically called 
// on a timer alarm event.
void IRAM_ATTR onRedTimer(){
  digitalWrite(RED_LED, !digitalRead(RED_LED));
}

void IRAM_ATTR onGreenTimer(){
  digitalWrite(GREEN_LED, !digitalRead(GREEN_LED));
}


void setup() {
  pinMode(RED_LED, OUTPUT);
  pinMode(GREEN_LED, OUTPUT);
  
  Red_timer = timerBegin(0, 80, true);  // use tiemr 0 and set prescale to 80 so 1 tick is 1 uSec
  timerAttachInterrupt(Red_timer, &onRedTimer, true); // point to the ISR
  timerAlarmWrite(Red_timer, 1000000, true);  // set alarm every 1 sec
  timerAlarmEnable(Red_timer);  // enable the alarm

  Green_timer = timerBegin(1, 80, true);  // use tiemr 1 and set prescale to 80 so 1 tick is 1 uSec
  timerAttachInterrupt(Green_timer, &onGreenTimer, true); // point to the ISR
  timerAlarmWrite(Green_timer, 500000, true);  // set alarm every 0.5 sec
  timerAlarmEnable(Green_timer);  // enable the alarm



}

void loop() {

}