Hi to both of you I missed one thing.
When TMR0 used as a counter when ever it detects a pulse it will update the TMR0.
Yes
If the PIC is doing some other work for example when its doing multiplex no need to check everytime the T0IF bit it will automatically update the input pulses while doing multiplex routine.
Tell me am i right?
Yes if I understand you correctly. The counter updates automaticaly on every input pulse. This is done without any action from the PIC CPU. The CPU is free to run other code while the counter is counting.
Think of the timer module as a device that is seperate from the CPU. The timer works independantly of the CPU. The CPU can set and read the timer registers, the timer can set the IF flag and/or generate an interrupt. That is the connection between the CPU and the timer.
You can setup the timers and forget about them till you see the IF flag change or service a timer generated interrupt.
Now the only problem is TMR0 doesn't support 1:1 pre scaller it has 1:2 prescaller.So the result I have to double every time so the final result is all the time is even numbers.
Not a problem. If you set the Prescaler Assignment bit (PSA bit) to 1 Timer0 will not use the prescaler. Same results as if the prescaler had a 1:1 setting.
Code:
bit 3 PSA: Prescaler Assignment bit
1 = Prescaler is assigned to the WDT
0 = Prescaler is assigned to the Timer0 module
Thanks