Arduino DueTimer Library

I was using the DueTimer library by ivanseidel. Initially it was working fine but suddenly I noticed that using the interrupt with high frequency causes the micros() and millis() function to become erratic. Can someone test the code below and see if it is hardware related issue? I tested the code before with much high frequency (3600 Hz) or 278 microsecond period and I swear it was working fine.

Board: Arduino Due
Baud: 115200
Arduino v1.5.8

#include <DueTimer.h>
void firstHandler(){

void setup(){
	Timer1.attachInterrupt(firstHandler).start(500); // Every 500 microsecond

void loop(){}

This is the output that I get whenever I run that code:

Here is the link to the DueTimer library: GitHub - ivanseidel/DueTimer: ⏳ Timer Library fully implemented for Arduino DUE

Thank you for your time. :slight_smile:

Firstly don't call Serial in an ISR. It happens to work ATM on the Due because the
way HardwareSerial is currently implemented, but don't rely on that staying that way.

You are trying to write 5 characters every 500us at 115200 baud - think about it, you are
likely busy-waiting in the ISR for the UART long enough to block the millis() interrupt and
miss your own timer interrupts...