pwm 40 khz
Hi tamer1221
I normally work in assembler - much easier - and not subject to poor compilers!
Check that your compiled C is loading the correct RAM banks.
I used a slightly different value for CCP1CON but that is for 50%M/S ratio.
I have just run the code below on an 16F877A through MPLAB 8.30 and
ICD2 Debugger with no problems.
As a bonus if you HALT the 16F887A via the ICD2 Debugger the PWM keeps
running and you can modify the registers through the WATCH window and see
the results on a scope straight away - good for fine tuning hardware!
This also works:
MAKE an .asm file containing just an END statement
Program the processor via the ICD2 Debugger
Run the processor, HALT the processor
then - just poke the registers via the Watch Window with
the right values and the PWM will start running.
hope this helps
Polymath
;------------------------------------------------
;************************************************
;
banksel PORTC ; bank 00
clrf PORTC
;
banksel TRISC ; bank 01
clrf TRISC
;
movlw B'00011000'
movwf PR2
;
banksel T2CON ; bank 00
movlw B'00000100'
movwf T2CON
movlw B'00001100'
movwf CCPR1L
;
movlw B'00101100'
movwf CCP1CON
;
forever goto forever
;
;------------------------------------------------
;************************************************