econjack:
@John: I'm using Timer1 to drive a simple pulse using the setup code:I get a great square wave out for 1000Hz. When I want to change the frequency via period at runtime and do the assignment of a new period into OCR1A, things work fine. However, if I raise the frequency to something above 2.5KHz, the frequency doesn't change. The calculation for period should work well past 2.5KHz. Anything ring a bell here?
It should be a problem for frequencies BELOW 2.5 kHz. Frequencies too low without a prescale will give you a value of TOP greater than 65535, the largest number that fits in a 16-bit register.
Calculate TOP using unsigned long values. If TOP > 65535 set the prescale to 8 and use TOP/8. Otherwise use a prescale of 1 and use TOP directly. For even lower frequencies expand that to higher prescales.