mramos1
Active Member
My last chance before I go to assembler again. Below is an attempt to read a VDD/VSS pot on A.0 and blink an LED on B.0 (maybe I should move it to B3 like William said use PWM). 8mhz internal osc 16F88.
Anyway in MPLABS I see the ADC works (range 0-255 no problem) and I see the value load in "count" and "value" before calling the Vdelay_ms routine. The LED blinks but no change in the speed and it is very slow 100ms (50/50).
I can only assume I do not have some pic register set correctly. Any ideas?
I thought TRISB = 0 would make it all output..
Anyway in MPLABS I see the ADC works (range 0-255 no problem) and I see the value load in "count" and "value" before calling the Vdelay_ms routine. The LED blinks but no change in the speed and it is very slow 100ms (50/50).
I can only assume I do not have some pic register set correctly. Any ideas?
I thought TRISB = 0 would make it all output..
Code:
program P16f88
Symbol LED = 0
Symbol POT = 0
dim count as word
dim value as byte
main:
TRISA = $FF ' PORTA is input
PORTB = 0
TRISB = $00 ' Pins PORTB output
' ADCON0 = $81 'Configure analog inputs and Vref
ADCON1 = $80
' ANSEL = $81
value=adc_read(POT)
DO
count=value
ClearBit(PORTB,LED)
VDelay_MS(count)
SETBIT(PORTB,LED)
VDelay_MS(count)
LOOP until 1 = 0
end.