General Purpose Timer

General Purpose Timer (GPT) allows to measure precisely time and execute actions right after timer reaches zero. This allows a very accurate control over time critical processes as well as contolling servo motors. To set up a user handler function to be called by GPT define it as described here using ZUNO_SETUP_ISR_GPTIMER macro. PWM/analogWrite() can not be used when GPT is enabled! WTIMER0 timer is used GPT is configured using the following functions:
  • zunoGPTInit()
  • zunoGPTEnable()
  • zunoGPTSet()
ZUNO_SETUP_ISR_GPTIMER(gpt_handler);

unsigned long count_gpt = 0;

void gpt_handler() {
    count_gpt++;
}

void setup() {
    zunoGPTInit(ZUNO_GPT_SCALE1024|ZUNO_GPT_CYCLIC);	
    zunoGPTSet(65000);
    zunoGPTEnable(1); 
    
    Serial.begin(115200);
}

void loop() {
    Serial.println(count_gpt);
    delay(1000);
}