Hi,
I have used the 16F877 PIC Processor for about a year and I have a little project I wanted to use the 16F88 for. I am having problems reading the analog inputs, I think. I have setup for only AN0 and AN1 to be analog in and am setting Port b 0-3 as indicators to see voltage level vdd-vss. Here is my testing code but I can't see to get it to work.
DEFINE LOADER_USED 1
OSCCON = %01100111
TRISA = %00000011
TRISB = %00000000
PORTB = %00000000
ANSEL = %00000011
ADCON1 = %10000000
CMCON = 7
DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
CTA VAR BYTE
main:
ADCIN 0, CTA
ledtst1:
IF CTA > 50 Then tst2
PORTB = %00000001
GoTo cont
tst2:
IF CTA > 125 Then tst3
PORTB = %00000011
GoTo cont
tst3:
IF CTA > 200 Then tst4
PORTB = %00000111
GoTo cont
tst4:
PORTB = %00001111
cont:
Pause 10
GoTo main
End
It does not give me any errors nor does it work. I am using MELabs Pro Basic compiler version 2.44. I have ordered the 2.45 but have not gotten it yet.
Any sugguestions?
Thanks,
Brian
Bookmarks