> PWM period = (PR2+1) x 4 x Tosc x TMR2Prescale > > At 4MHz (Tosc = 0.25uS) this gives a minimum frequency of: > > 1 / ((255+1) x 4 x 0.25E-6 x 8) = 488Hz so I'm probably doing > something wrong... The pre-scaler has 1:1, 1:4 and 1:16 flavours, there's no 1:8 > As you noted, there is a tradeoff between resolution and > frequency. What I don't quite understand is that on your web > page you mention that your upper frequency is limited to > 6700Hz due to having to read the ADC. It's not so much that the frequency can't go higher, it's that the wave breaks up with the code the way it is. One thing I'd need to do if I wanted higher speed PWM (which I don't in this case) is to tidy up the ADC routine as much as possible and read just one pot per ISR iteration, cycling through however many are attached on successive IRQs. The PWM doesn't have to be modified on each cycle, although at low frequencies the time between readings for a particular pot may be too long, so the s/w needs to know the frequency in order to adjust measurement timing > If you don't need the higher frequencies you could just use a lower > frequency clock e.g. 500Khz would give you a lowest frequency of > 61Hz and a max frequency of just under 2KHz (for 8 bit resolution) If I did run the PIC at 8196Hz to get the lowest PWM required of 0.5Hz (with a 1:16 prescaler), the maximum speed attainable would be ((0.5/244) x 6700) x 16 = 220Hz (by changing to a 1:1 prescaler). This is too low for the top end, so I still need to decrease Tosc -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads