easy way
Code:
;pic12f683
#CONFIG
cfg = _INTOSCIO
cfg&= _WDT_ON
cfg&= _PWRTE_OFF
cfg&= _MCLRE_ON
cfg&= _CP_OFF
cfg&= _CPD_OFF
cfg&= _BOD_ON
cfg&= _IESO_ON
cfg&= _FCMEN_ON
__CONFIG cfg
#ENDCONFIG
DEFINE OSC 8
OSCCON=$70
CMCON0 = 7
TRISIO = %111011 ;gp2= output
ANSEL =0
; hpwm Channel, Dutycycle, Frequency
hpwm 1,128,600 ; 50% 600 hz
mainloop:
; do stuff
goto mainloop
to do it manually
Code:
TRISIO = %111011 ;gp2= output
t2con=5 ; set up timer/pr2 for frequency and pwm bits ; note this is not equivalent to above resulting freq is ? [you work it out]
PR2 = 255;
CCPR1L = pulswidth ; set pulsewidth high bits
ccp1con=12 ; set ccp reg and or pulsewidth low bits
Bookmarks