Using timer of Arduino Due to create internal interrupt

Hello, this is my first post over here. :)

I am new to ARM processors, and started with Arduino Due. For my project, I need to print some data every 2 seconds on LCD. In these 2 seconds, many operations involving analogRead and many computations will take place.

How do I set the internal timer for 2 seconds, such that it generates interrupt for the ISR in which the command for printing data will be there?


I think you should be able to do this with the Blink without Delay approach. In that approach, the processor carries on doing a whole load of stuff while keeping an eye on the clock each time through loop(). If the desired interval has expired an led is blinked. If interval is not expired, the led stays as it is.

In your case, instead of blinking the led, if the interval has expired print the data; if it hasn't, don't.

No interrupt required.

Okay. I saw the code, and it will work hopefully. Thanks :)

Not really a good suggestion. It's dangerous to use Serial.print() inside an interrupt routine. You would have to use the interrupt to set a variable which the main loop checks regularly to fire off the print function.

Use the BWOD technique in the main loop.