PDA

View Full Version : ANSEL command



Samoele
- 9th January 2009, 13:13
Hello,

I was made one simple test program with ADC. I have problem with MCS compiled. I don't understand what is wrong with ANSEL = 1 command? Into status line write syntax error!! When disable this ANSEL command compiled finished ok. I was trying compile with PBP2.50b and MPASM and result is equal.
Who is problem here?

@ Device PIC12F675,WDT_ON,PWRT_ON,PROTECT_OFF,MCLR_OFF,BOD_ OFF
ANSEL = 1
ADCON0 = 3
CMCON = 7
DEFINE OSCALL_2K 1
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50

w0 VAR WORD
w1 VAR WORD
w2 VAR WORD
w3 VAR WORD
w4 VAR WORD
w5 VAR WORD
w6 VAR WORD
w7 VAR WORD
out VAR GPIO.2

meritev: ADCIN 0, w0


w1= 1023-w0/2

high out
pause w1
low out
pause w1

goto meritev

Acetronics2
- 9th January 2009, 13:46
[ Humour ON ]


Who is problem here?


You really sure to want the answer ???

[ Humour OFF ]

Now,



DEFINE OSCALL_2K 1


MUCH Better :



DEFINE OSCCAL_1K 1





ANSEL = 1
ADCON0 = 3


Much better



ANSEL = %01110001 ; RC - GPIO.0 ana.
ADCON0 = %10000000 ; for 10 bits ... right justif !!! - wait for ADCIN to start.



AND For the end ...

You did not define the I/Os ...



TRISIO = %11001001 ; if you want GPIO.0 to work as an ADC input. ( see manual ! )



At this level ...
You MIGHT open

1) THE Manual
2) The Pic relevant Datasheet ...

Alain

Samoele
- 9th January 2009, 14:01
thanks Alain

I was repair our routine and result is no unchanged. Here must be another problem :(

show attachment

Acetronics2
- 9th January 2009, 14:30
I do not think this:



@ Device PIC12F675,WDT_ON,PWRT_ON,PROTECT_OFF,MCLR_OFF,BOD_ OFF


exist with PBP, PM, MPASM, nor MCS ...

last effort ... go on !!!

Alain

Samoele
- 9th January 2009, 15:33
Hello!

I was repaired this problem.
I was copy compiled file on location where have MCS and run it :