-
1 Attachment(s)
ANSEL command
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
-
[ Humour ON ]
Quote:
Who is problem here?
You really sure to want the answer ???
[ Humour OFF ]
Now,
MUCH Better :
Code:
ANSEL = 1
ADCON0 = 3
Much better
Code:
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 ...
Code:
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
-
1 Attachment(s)
thanks Alain
I was repair our routine and result is no unchanged. Here must be another problem :(
show attachment
-
I do not think this:
Code:
@ Device PIC12F675,WDT_ON,PWRT_ON,PROTECT_OFF,MCLR_OFF,BOD_ OFF
exist with PBP, PM, MPASM, nor MCS ...
last effort ... go on !!!
Alain
-
Hello!
I was repaired this problem.
I was copy compiled file on location where have MCS and run it :