At 12:42 PM 08/07/2000 -0500, you wrote: >> >>10 9.7 39.06 > >How did you get to this? >I must be missing something.. I just ran the numbers and got: > I just took the numbers for 20 Mhz from table in the datasheet, and scaled for the slower xtals. Tosc scales directly with xtal freq. As detailed by others, this gets a little confusing as there are "Standard res" and "High res" modes, where the latter requires the pain in the neck business of using the 2 extended bits in the CCPxCON reg. Eg, for 20 Mhz, you get 10-bit PWM at 19.53 Khz only by using these bits. Std res is 8-bits, etc. =========== >Period = (PR2+1)*4*Tosc*Prescale >The shortest period attainable is therefore 0.4uS (T0sc = 0.1uS, Prescale = 1) >However, the resolution available at this period is not workable (1 bit!) Yes, but the PWM rate would be 2.5 Mhz too!! For something more usable, from the datasheet table for 20 Mhz xtal and std 8-bit PWM, use PR2 = 0FFh [max value], so Period = [255+1]*4*.05usec*1 = 51.2 usec --> 19.53125 Khz. Put FFh into PR2. Use 0-FFh in CCPRxL for 8-bit res. Use 2 extended bits in CCPxCON for 10-bit res --> concats the lowest 2 LSBs. =============== >The value in DC1 controls the duty cycle, but I cannot use a wider word >than that in PR2. >IOW if PR2 is 00001110 then I can only use up to 00001111 in DC1, limiting >the PWM resolution to 4 bits. >To get 6 bit resolution, I have to use at least 3E (00111110) in PR2, so >the period drops to 102uS You have the basic idea here - ie, different PWM resolutions involve setting some value in PR2 < 0FFh, plus a "fractional" value of that in CCPRxL - ie, the #bits used in PR2 dictates the PWM res, and duty value is always "relative" to the PR2 value. - danM -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics