Quote Originally Posted by wasssup1990 View Post
Hello. I am not sure how to setup my PIC16F877A to run a looping section of my code every 10ms. A rate gyro must be read every 10ms consistently so that my integeration calculations don't go crazy. I've read the Timer0 section of the datasheet but I just don't understand it well enough to achieve what I want. I am using PIC Basic PRO.
If I have missed an important piece of information here please ask me for it.
Thankyou.
Use an LED for initial testing, make blinky first, otherwise, I'll bet you'll drive yourself crazy trying to get it to work right.
One 'easy-ish' way to get it to work...
Set up timer 0 to interrupt on overflow, get an 'On Interrupt' stub to work blinking an LED. Change the Tmr0 prescaler to 1:64. You'll get an interrupt every 16.384ms instead of 10ms. Yes, it's a bit longer than what you want, but you can easily scale the results from the 16.384ms interrupt to make them look like the results from a 10ms interrupt.
16384/10000 = 1.6384.
No, PBP can't divide by a fractional number...but, you multiply it up by a large number and divide it back down by a whole number, keeping the ratio the same to keep the numbers correct...i.e.
16384/10000 = 1.6384 which is the same as
32768/20000 = 1.6384 which is the same as...and so on and so on...
Or, set up Tmr1 as a 16 bit timer that kicks off every 10ms...just like the other guys said...
But $20 says you're biggest problem will be understanding how to get the interrupt to work in the first place...