TimerOne library

I want to use the TimerOne library to make two interrupt routines. Is this possible or can you attach only one? What I would like to do is in the first interrupt is reading an input every 0.5ms, the second interrupt should send the collected data over the serial port to my computer for further processing when e.g. 80 samples are taken.

If yes, how do you do it? Can you just initialize the timer twice?
If no, what are my other options?

That is really slow. Why use a timer, when timer 0 is already running for you?

the second interrupt should send the collected data over the serial port to my computer for further processing when e.g. 80 samples are taken.

You can’t do (that much) serial IO in an interrupt service routine, where interrupts are disabled.

You do NOT need a timer-generated interrupt to send data after 80 samples are taken. Count the number of samples in the one timer interrupt (if you decide that you just HAVE to use timer interrupts at all).

In loop(), when that number of samples has been taken, send the data.

Can you just initialize the timer twice?

Can you get wet twice? No. The second time you try, when you are already wet, will prove useless.

Ok thanks for the clarification.

@aarg: What do you mean exactly? Btw the example I gave is just a possible sampling time, I want to sample 50Hz signals so 40 samples in one period should already give a good indication. I will go higher if possible but I'm exploring the capabilities a bit...

@PaulS: I think that I have to use timer interrupts to be sure that the signals that I measure are sampled at regular time intervals. I would like to collect the data with Python and do an FFT on it afterwards. I'm not exactly sure but I taught that it was better if the points have the same time spacing.

Simon,

alternative for timerone attached, good luck

Luc

multitasking_2016_07_29.ino (1.17 KB)