What is the use of multiple timers in PIC if we cannot create steady frequencies from each timer?

Click to expand...

timers are simply counters. they count number of pulses. if the clock frequency is not stable, neither delay obtained through timers can be stable. PIC comes with variety of oscillator options. internal clock is cheap as it does not require external components but it is not nearly as stable as crystal oscillator. as MrChips already stated, if you need repeatability and precision, use crystal.

It describes very simple code to make any frequency you want from any timer and any XTAL frequency. It can also be repeated in code to make a number of simultaneous and independent frequencies, all from the same timer.

If the issue is this:
"The time spent in executing one timer subroutine affects the other timer subroutines and hence no steady frequency"

I'm afraid that no, there is no way out of this, if you need to execute code at several fixed frequencies. You must see that if the timers are all independent, you risk a situation where it is the right time to execute code for more than one of them at once, and the processor cannot do that.

What you could do is designate one timer as the most important one, and it would always have a regular execution time. The others wouldn't be as accurate. Or could you set up a PIC to control external clocks which would each be independent? But then all you could do would be to drive logic outputs, not run code in the PIC.

Sorry JohnP, but I disagree. The page I linked to has simple code examples that will generate any freq from within the interrupt.

The code can be repeated multiple times, to generate multiple *exact* frequencies simultaneously, all from the one simple interrupt. I once coded an 8voice polyphonic synth using one TMR0 interrupt using the same principle.