I found a chart on the net. It pretty much states that 8 mhz is too slow for 19,200 so I jumped to a 20 mhz and all is well. Even recalibrated my timer routines.
Thanks for all the help here.
Richard
I found a chart on the net. It pretty much states that 8 mhz is too slow for 19,200 so I jumped to a 20 mhz and all is well. Even recalibrated my timer routines.
Thanks for all the help here.
Richard
Okay, See if I learned anything.
OSC 20
20 mhz / 4 = 5 mhz
1 second / 5,000,000 = 0.0000002
Each tick is 0.0000002 seconds
So, I would need 50,000 ticks to make it fire 100 times per second.
Since the timer counts up to 65535 and we roll over I would do this....
65,535 - 50,000 = 15535
Preload the timer with 15535 then
0.0000002 x 50,000 = 0.01
So the Timer would fire every 100 times per second
Why then do I have to preload the timer with 15543 to make it dead on? Is this just a difference in osc frequency.
65,535 - 50,000 should be 65,536 - 50,000. Your load value would be 15536.
It takes 65,536 cycles (0 to 65,535 + 1 additional cycle) for the 16-bit
overflow or roll-over from 65,535 back to 0.
Because the timer is still counting while you're doing things after it rolls-over.Why then do I have to preload the timer with 15543 to make it dead on? Is this just a difference in osc frequency.
You need to compensate for time passed (timer counts) while your program is
doing something after the roll-over. The timer is still counting during this time
frame.
You can either write an adjusted value to the timer, or simply "add" your real
value to the existing count already held in the timer registers.
Adding the real value to the existing timer count is the prefered method as
long as your program doesn't tinker around long enough to where adding to
the count would cause immediate over-flow after the add.
If the time is not precise enough for you, you can use CCP1 in order to restart Timer1 automatically.
But I think it is to heavy for a beginner.
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
Oh, the time is plenty close enough for what I'm doing. I just asked so I could learn and take notes.
Thanks agin for the help...
Bookmarks