'Using PIC16F18857
DEFINE OSC 8 '8MHz
OSCFRQ=$03
TRISA=0 'all outputs
ANSELA=0 '1=Analog, 0=Digital
TRISB=0 'all outputs
ANSELB=0 'all Digital
TRISC=0 'all outputs
ANSELC=0 'all Digital
'PPS MODULE (Peripheral Pin Select)
RA2PPS=$0E 'PWM6OUT OUTPUT on RA2
RA3PPS=$0F 'PWM7OUT OUTPUT on RA3
' *** HPWM format as follows:
'HPWM Channel, Dutycycle, Frequency
HPWM 1, 0, 1000 '51/255 or 0% duty cycle pin 13
HPWM 2, 102, 1000 '110/255 or 40% duty cycle pin 12
HPWM 3, 153, 1000 '153/255 or 60% duty cycle pin 26
HPWM 4, 204, 1000 '204/255 or 80% duty cycle pin 21
HPWM 5, 127, 1000 '240/255 or 50% duty cycle pin 6
' Now, we need to select the same timer for PWM6 and 7 that is used for CCP1 (TMR2)
CCPTMRS1=%00010101
PWM6CON=%10010000 'enable and active high
PWM7CON=%10010000 'enable and active high
'set at 50% for both to test
PWM6DCH=128:PWM6DCL=0 'PORTA.2 (pin 4)
PWM7DCH=128:PWM7DCL=0 'PORTA.3 (pin 5)
keepgoing:
pause 500
goto keepgoing
end
Bookmarks