Hi all. I'm a relatively new user to pics. I have a 16F74 which i'm trying to use the peripherals on.
The pwm and simple code is working well, but I'm having the following problem with the adc:
My code is very simple:
#chip 16f74, 20
#include <lowlevel\a-d.h>
#byte adcresult
main:
adcresult = ADRead(AN0)
end
When I compile I get a syntax error in line 225 of a-d.h, which is 'ADRead = ADRES', which is where the return value of the function is written (I think). Is there something I'm doing wrong???
Thanks,
Chay
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is strange, as using the latest update (http://gcbasic.sourceforge.net/newfiles/update.zip) the only thing I had to do was use ReadAD instead of ADRead. Using ADRead gave me an array/function not declared error. No trouble otherwise.
There are a few things you've done in your program which GCBASIC does for you automatically:
- #byte isn't a directive in GCBASIC. All byte variables are automatically declared.
- There's no need to include anything in the lowlevel directory - GCBASIC does this by default.
- "end" is added by GCBASIC at the end of a program
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all. I'm a relatively new user to pics. I have a 16F74 which i'm trying to use the peripherals on.
The pwm and simple code is working well, but I'm having the following problem with the adc:
My code is very simple:
#chip 16f74, 20
#include <lowlevel\a-d.h>
#byte adcresult
main:
adcresult = ADRead(AN0)
end
When I compile I get a syntax error in line 225 of a-d.h, which is 'ADRead = ADRES', which is where the return value of the function is written (I think). Is there something I'm doing wrong???
Thanks,
Chay
Hi,
in the line "adcresult = ADRead(AN0)" try a zero instead of the "AN0"
Like: "adcresult = ADRead(0)"
Has worked for me on the 16F887.
Mike
Agreed. This is part of the solution. The other part is to use the corret '\' rather than '/' in the include statement. Doh!
Chay
This is strange, as using the latest update (http://gcbasic.sourceforge.net/newfiles/update.zip) the only thing I had to do was use ReadAD instead of ADRead. Using ADRead gave me an array/function not declared error. No trouble otherwise.
There are a few things you've done in your program which GCBASIC does for you automatically:
- #byte isn't a directive in GCBASIC. All byte variables are automatically declared.
- There's no need to include anything in the lowlevel directory - GCBASIC does this by default.
- "end" is added by GCBASIC at the end of a program