Noob Timer Questions

I need to do all kinds of things!

Not least is to use a hardware timer to constantly time and then jump to an interrupt to do some stuff

I wrote/ripped this program

#include <MsTimer2.h>

void DOSTUFF()
  static boolean output = HIGH;
  static boolean output2 = LOW;
  digitalWrite(13, output);
  digitalWrite(13, output2);

void setup(){
  pinMode(13, OUTPUT); 

  MsTimer2::set(20, DOSTUFF);
void loop(){


It uses MsTimer2

MsTimer2::set(20, DOSTUFF);

This sets the timer count to 20ms and the program jumps to the void DOSTUFF part which it executes then jumps back to the main loop which is empty and waits for the next time count

I have written pin 13 high for a ms just to test the program and it seems to be working, I monitored the output with my scope and it looks as expected (see attached pics)

Now I want a timer to work in microseconds and this is my question I have been on all morning trying to change the prescale values but I dont know if I can do that

So if anyone can tell me what I need to do to make my program work in us instead of ms I will send you a free mars bar!

Perhaps you ought to tell us what you are trying to accomplish, not what you think you need to do to accomplish that goal.

I need to do all kinds of things!

While also doing something every n microseconds?

I already tried that!,82049.0.html,81805.0.html

But its so complicated it puts people off (I think!)

Seeing how I absolutely must get to the bottom of this I though I would break it all down into simpler tasks the first task is to use a timer to increment a table

I can programme a table to increment so that shouldnt be a problem the problem is in setting up a timer and it leaves me confused

I have so many questions like

What if I wanted my programme to run inthe standard loop and to not branch elsewhere is that possible?

for the timer to wait before the next line and then go though loop back and rewait the relevant time?