With the 1:16 prescale, you should have an output pulse at 244Hz (4mhz / 4 / 16 / 256 ), if my math is correct. And your portb.7 high pulse will only be 1us, maybe 2us. Disable the prescale, and you should get 3906.25Hz on the fast pin and if you rewrite the code to include the slow pin, you should get a bit slower than 1hz on the slow pin (just for testing of course). The way to speed this up is to preload tmr0 with a higher number to get the overflow interrupt to kick in faster. Problem with this is that once you get up to a certain point, you won't have enough left over cycles between interrupts to do anything useful, except jump and resume into and out of the interrupt routine. And I'm talking about using the Instant Interrupts method, not the PBP On Interrupt method. With the PBP On Interrupt method, you use even more cycles due to overhead when using PBP.
And the tmr0=2 to correct for missed cycles? That won't correct for missed cycles, all that will do is reset tmr0 back to '2'. That 'missed cycle correction' is only used when you are preloading tmr0. So, say you want to preload tmr0 with 100, you'd actually load it with 102 since tmr0 will stop for a couple of cycles while it's being reloaded.
If you're looking to update at 60hz to provide a visually pleasing effect, so you won't see a flicker, I really wouldn't worry about that until you get below about 30hz. When I'm messing with LEDs, I (or anybody I show my projects to or whatever it is I'm working on) can't really see a flicker down to about 25hz, and only then if I look at the LEDs at certain angles.
But if you're hellbent on getting this to work (and I think it can work), you've got to get a fast PIC (40Mhz would be optimal, but the '648 is limited to around 20Mhz, might be fast enough, I'm just thinking an 18F series @ 40Mhz would give you the extra muscle to get the job done better and leave you more room to play with), make your code tight, and one the thing that'll help you out a bunch is to download and make use of those 'Instant Interrupts'. PBP's On Interrupt could be used to get the code working and debugged, then you could switch over to the other interrupt method, but I think you'd be better off with the Instant Interrupt's from the beginning.





Bookmarks