Re: Low frequency & High frequency at same time for different timer ?
Yes, I am sure it can be done,
but Not without some wery detailed reading of the datasheet,
and careful coding.
There are new features available in Timer 0,
in PIC18F25Q10 and some other new families like PIC18FxxK42, and PIC18FxxK83.
Among other, Datasheet claim that Timer 0 may operate in Sleep mode when Secondary Crystal OScillator (SOSC) is selected as clock input to the timer.
Timer 0 may now operate as a Period Timer when running in 8 bit mode,
by using TMR0H as Period Register.
Timer 0 in these new devices have a very large Prescaler range.
Also, with these devices, there are now possibilities to chain hardware timers together,
by selecting rollover event in one timer, as clock input in another timer.
So it may possibly be done entirely in hardware.
Note that: Using a large prescaler value together with 16 bit mode counting,
it will be possible to reach about a million count with Timer 0 alone.
But be aware that doing a software reload of the TMR0H and TMR0L registers in 16 bit mode,
as is common practice with 16 bit timers to achieve a wanted timer period,
will clear the prescaler counter, and thus may cause the timer period to drift.
Note that: RD16 bit in Timer 1 (and 3 and 5) have a very different effect than T016BIT in Timer 0.
T016BIT in PIC18F25Q10, is the same as MD16 bit for Timer 0 in many other PIC devices.
I would normally want to use Timer 1 with the SOSC oscillator at 32.768 kHz,
and Timer 0 or one if the 8 bit Timers with the MHz clock signal as input.
If the system clock is higher than 4 MHz, that is Fosc/4 is higher than 1 MHz,
I would use Prescaler to take the frequency down to 1 MHz,
use Period register value = 249, for 250 counts, and Postscaler 1/4,
to get a 1 millisecond period. There are several combinations possible.
Then count in Software to 1000 milliseconds for a 1 second period.
This will give possibilities of cycle correct counting, both for the 32.768 kHz oscillator,
and from the xMHz system clock frequency.
And possibilities for cycle correct comparision of frequency or drift between crystal oscillators.
Or you may use it to compare and tune the internal HFINTOSC oscillator.
It will be possible to keep the 32.768 kHz timing active also during sleep mode,
whether Timer 0 or Timer 1 is used with the SOSC oscillator.
In addition, there will be a 1 millisecond tick signal and a millisecond count available in software,
without using another timer.
There is a trick possible to avoid loosing ticks when updating the Timer 1 counter registers,
when using a 32.768 kHz watch crystal oscillator with a 16 bit timer:
Use the Read/Write 16 bit mode bit: T1CONbits.RD16 = 0;
and update TMR1H register only: TMR1H = 0x80; // Do Not touch TMR0L register.
This will give a 32768 count increment to the Timer value which will otherwise run to 2 seconds if there is no timer update.
To be successful, this must be done within 8 milliseconds after a Timer 1 rollover have occurred.
This may be used with Timer 1, Timer 3, or Timer 5. It will not work with Timer 0.