Hi! I just purchased some PIC12F683s and am having some problems. The simple program I wrote takes a 0 to 5V analog voltage from a 5k potentiometer and this adjusts HPWM. I have 0.1uF caps in place from VDD to VSS and another on the pot's wiper. At the moment, the HPWM drives an LED. Ultimately it will feed a mosfet that will control a small toy motor.
Compiler - PisBasic Pro 2.47
Using MicroCode Studio
Pic - PIC12F683
I get a syntax error on the line "CMCON0 = 7" which disables the comparators. Yes, I tried "0" and "O" and just "CMCON". As well, I am getting irratic behavoir from the HPWM where as I adjust the pot, the duty cycle jumps around irraticaly. I used an oscilloscope to verify the behavior.
Any advice would be appreicated. The program is below;
INTCON = %10001000 ‘internal oscillator
OSCCON = %01110000 ‘ 8mHz
CMCON0 = 7 'Comparators off
GPIO = %00000000 'outputs low
TRISIO = %00010000 'GP3 as input
ANSEL = %00111000 'AN3 analog
'Define ADCIN parameters
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
Define CCP1_REG GPIO 'PWM Output on gpio
Define CCP1_BIT 2 'Bit 2
‘ Variables
Posit var Word
Speed var byte
Pause 100
Scan:
ADCIN 3, Posit ' Read channel AN3 to Posit
Speed = Posit/4
HPWM 1,Speed,1000
Pause 10
Goto Scan
End
Bookmarks