I find the formulas obfuscate things. Using the MElabs example, with OSC=4MHz each instruction cycle takes 1µS. The period for 1kHz is 1/1000=.001=1000µS=1000 instruction cycles. With the prescaler set to 4, 1000 becomes 250 and since it's Base0 it becomes 249. The duty cycle is the number of instruction cycles that the output is high. 20% of 1000 = 200 and 80% of 1000 = 800. All you are doing is defining the period and duty cycle in numbers of instruction cycles. Once you grasp what's involved you can do the calculations in your head.Originally Posted by paul borgmeier
Bookmarks