I've never had a problem with 18F25K20 device and PWM. So just to prove to myself that the chip is not at fault I wrote a simple snippet program to configure the PWM for 36KHz and 38KHz and ran it in the ISIS simulator. The results were as expected:
Code:
Device = 18F25K20
Declare Xtal = 4
Declare Optimiser_Level = 1
' For Approx 36KHz 50% duty cycle (Actually 35.715KHz)
(*
T2CON = %00000100
PR2 = 27
CCPR1L = % 00001110
CCP1CON = % 00001100
Output PORTC.2
*)
' For Approx 38KHz 50% duty cycle (Actually 38.461KHz)
T2CON = %00000100
PR2 = 25
CCPR1L = %00001101
CCP1CON = %00001100
Output PORTC .2
If you were running your tests on the Amicus18 platform, did you remember that Amicus18 uses a 16MHz crystal, but your program is set for a 4MHz crystal.