This is the code I used
Its the same pwm set up as I have used on a 18f4520
Code:
;-------------------------------------------------------------------------------;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings
Device = 18F25K20
Declare Reminders Off
@ CONFIG_REQ = 0 ; Override Compiler's configuration settings
Asm-
Config FOSC = HS ;HS oscillator
Config FCMEN = OFF ;Fail-Safe Clock Monitor disabled
Config IESO = OFF ;Oscillator Switchover mode disabled
Config PWRT = On ;PWRT enabled
Config BOREN = OFF ;Brown-out Reset disabled in hardware and software
Config BORV = 22 ;VBOR set to 2.2 V nominal
Config WDTEN = OFF ;WDT is controlled by SWDTEN bit of the WDTCON register
Config WDTPS = 1 ;1:1
Config CCP2MX = PORTBE ;CCP2 input/output is multiplexed with RB3
Config PBADEN = OFF ;PORTB<4:0> pins are configured as digital I/O on Reset
Config LPT1OSC = OFF ;Timer1 configured for higher power operation
Config HFOFST = OFF ;The system clock is held off until the HFINTOSC is stable.
Config MCLRE = OFF ;RE3 input pin enabled; MCLR disabled
Config STVREN = OFF ;Stack full/underflow will not cause Reset
Config LVP = OFF ;Single-Supply ICSP disabled
Config XINST = On ;Instruction set extension and Indexed Addressing mode enabled
Config Debug = OFF ;Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
Config CP0 = On ;Block 0 (000800-001FFFh) code-protected
Config CP1 = On ;Block 1 (002000-003FFFh) code-protected
Config CP2 = OFF ;Block 2 (004000-005FFFh) not code-protected
Config CP3 = On ;Block 3 (006000-007FFFh) code-protected
Config CPB = OFF ;Boot block (000000-0007FFh) not code-protected
Config CPD = OFF ;Data EEPROM not code-protected
Config WRT0 = OFF ;Block 0 (000800-001FFFh) not write-protected
Config WRT1 = OFF ;Block 1 (002000-003FFFh) not write-protected
Config WRT2 = OFF ;Block 2 (004000-005FFFh) not write-protected
Config WRT3 = OFF ;Block 3 (006000-007FFFh) not write-protected
Config WRTC = OFF ;Configuration registers (300000-3000FFh) not write-protected
Config WRTB = OFF ;Boot Block (000000-0007FFh) not write-protected
Config WRTD = OFF ;Data EEPROM not write-protected
Config EBTR0 = OFF ;Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
Config EBTR1 = OFF ;Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
Config EBTR2 = OFF ;Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
Config EBTR3 = OFF ;Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
Config EBTRB = OFF ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
Endasm-
Declare Reminders On
;**** End of Fuse Configurator Settings ****
;-------------------------------------------------------------------------------
Xtal 4
Declare Create_Coff = On
' T2CON = 0b00000100; // prescaler + turn on TMR2;
' PR2 = 104;
' CCPR1L = 0b00110100; // set duty MSB
' CCP1CON = 210; // duty lowest bits + PWM mode
PR2 = 25 ' Set PWM Period for approximately 38KHz
CCPR1L = 13 ' Set PWM Duty-Cycle to 50%
CCP1CON = %00001100 ' Mode select = PWM
T2CON = %00000100 ' Timer2 ON + 1:1 prescale ratio
; HPWM 1, 127, 38000
Output PORTC.2
While 1 = 1
Wend
Here is a capture of the scope from isis for various CPUs running and a ref pulse from a pulse generator
The next snap is with a 18f4520 replacing the 18f25k20 as you can see all except the 25k20 look fine
I have an old tube scope and a pico scope. I'm working up at the house as the office is to cold and has to much junk in it, so no room for the big scope and the pico is temperamental.
All I want is a 38khz signal to try something out. I would have to go out and by a parts to build a new board and as its the week end I will not get them. The client is waiting and I cannot say I have to wait for Tuesday for parts.
I thought the Amicus would be fine but the pic used has issues