Counter Timer outside of Setup

Is it possible to manipulate the counter timer outside of the setup function? (A void is a function right?)

For instance, could I use these commands within a function:

cli();   
OCR5A = someVariable;                                       
sei();

Cheers in advance,

Pete

A void is not a function. Its a way of saying "this function doesn't return any value." Functions in C must always return a value and you must always specify in advance what type of variable it returns. Void is only provided for the humans reading the code. It's not an error to put return 0; in a void function although the compiler should flag this as a warning.

Yes, you can use your code inside any function. The setup() function is not special.

Brilliant! I am writing some midi-handling code from scratch, as certain aspects of the midi.h library were confusing me. Thought writing it all myself would help me understand what's going on. So far so good (though I'm only monophonic at the moment).

I better read up on what voids and functions are :smiley:

Cheers for your help, Pete

MorganS:
A void is not a function. Its a way of saying "this function doesn't return any value." Functions in C must always return a value and you must always specify in advance what type of variable it returns. Void is only provided for the humans reading the code. It's not an error to put return 0; in a void function although the compiler should flag this as a warning.

Yes, you can use your code inside any function. The setup() function is not special.

One minor correction:

"Functions in ANSI/ISO C++ must always return a value..."

Plain old c has no such requirement, and, I believe, neither does c++, except when ANSI/ISO enforcement are enabled in the compiler, which they are, by default, in Arduino builds.

Regards,
Ray L.