charlie, i'm using 2.6 and I can use HPWM, I dont see why you have to define ccp1, heres an example code for a 683 chip, reading a ADC and outputting pwm based on reading.
Code:
DEFINE ADC_BITS 10 ' A/D number of bits
DEFINE ADC_CLOCK 1 ' Use A/D internal RC clock
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us
RES1 Var Word ' A/D converter result
TRISIO.0 = 1 ' AN0 is input
TRISIO.2 = 0 ' PWM1 is output
AGAIN:
ADCIN 0, Res1 ' Read Channel 0 data
res1 = res1 / 256 ' 0-255
if res1 < 10 then res1 = 0 ' Low Auto Shutoff
HPWM 1, res1, 18000 ' PWM Pin, Setting, Frequency (20k Max)
pause 10
goto again
end
So with no defines it works fine, when HPWM command is used it will turn on the correct port and adjust the settings. If you dont use the hpwm it fuctions as a normal i/o port.
you shouldnt have to define CCP1, its hardcoded into that chip to begin with, CCP1 will always be on PORTA.2 to begin with, unless you force a change if allowed to move to a different pin (which yours does, but only if you tell it too) NOTE that I set my PWM output pin to a 0 as output, you dont have to do this either I dont believe, unless you want to use it as a I/O before engaging the PWM. It works so I havent changed it. Unless you decide to change output pins, or enable the other 4 hpwm modules on this chip, you shouldnt have to use anything but base code to set pwm. Oh and about the duty cycle, I believe if you dont set it to 10 bit it defaults to 8bit, the documentation says it can handle up to 10 bit and theses a section on how to adjust registers to allow for it. but if you dont change them... they should work as default from 0-255.
Bookmarks