Newbie HPWM / ADC question
Hello,
I am new to PICBASIC and I want to read from a pot and output to HPWM with PIC 16 F 88
OSCCON = $60 ' Internal oscillator frequency 4 Mhz
TRISA = %11111111 ' Set PORTA to all input
TRISB = %00000000 ' Set PORTB to all output
ANSEL = %01111011 ' Analog channel 0,1,3-7 Digital channel 2,8
ADCON1= %10000000 ' VDD & VSS as VREF
DEFINE ADC_BITS 10 ' ADC resolution 10 bit
DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 50 ' Sampling time 50ms
define OSC 4 ' Clock 4 Mhz
analogport VAR PORTA.0 ' Analog port pin RA.0
analogvalue VAR word ' Value digital 0 - 1024
pwmduty VAR word
main:
ADCIN analogport,analogvalue
pwmduty = analogvalue / 2
hpwm 1,pwmduty,7800
goto main
is the code correct, since I am not satisfied with the pwm output: the pwm turn off at 2.5v and portb.0 & portb.7 always on
btw fuse is set on mikroe programmer
Thanks