Society of Robots - Robot Forum

Software => Software => Topic started by: junior000 on January 26, 2008, 06:16:31 AM

Title: a/d c18 compiler
Post by: junior000 on January 26, 2008, 06:16:31 AM
hi i am using c18 compiler.

i have a problem executing the following program

#include <p18f4550.h>
#include <pconfig.h>
#include <adc.h>
#include <stdlib.h>
#include <delays.h>
#define ADC_1ANA_0REF    0b00001110
int result;
void main( void )
{
OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_1ANA_0REF, ADC_CH0 & ADC_INT_OFF);
Delay10TCYx( 5 ); // Delay for 50TCY
ConvertADC(); // Start conversion
while( BusyADC() ); // Wait for completion
result = ReadADC(); // Read result
CloseADC(); // Disable A/D converte
}

the error its showing is

C:\MCC18\bin\adc.c:10:Error [1203] too few arguments in function call
OpenAdc
Title: Re: a/d c18 compiler
Post by: paulstreats on January 26, 2008, 06:48:47 AM
hey, youve tried defining your own number of adc channels it doesnt work like this.

try leaving the 0REF off of the ADC_1ANA_0REF in OpenADC, your pic might not support optional refernces
Title: Re: a/d c18 compiler
Post by: rgcustodio on January 26, 2008, 08:11:39 AM
i agree with paulstreats you shouldn't go creating your own defines. you need to include the correct header file.

have you read the compiler's manual/programing guide as i suggested smewhere? i highly encourage you to read it.
FWIW the manual is here: http://ww1.microchip.com/downloads/en/devicedoc/C18_Lib_51297d.pdf
jump to page 14, and read on. if you will read the manual you will see that there are 3 "versions" of OpenADC()!
one is for PIC18CXX2, PIC18FXX2, PIC18FXX8, PIC18FXX39 series, another is for the PIC18C658/858, PIC18C601/801, PIC18F6X20, PIC18F8X20, and another is used for other All other PICs! based on the actual MCU you are using there are different defines that you can use! if you will jump to page 18, you will see that the version of OpenADC() used by other PICs require 3 argument. this would lead to the error you are having, you're only passing 2 arguments when 3 arguments are expected.

you might also be defining an incorrect MCU type, thus the compiler is using the a different version of OpenADC()! what is the actual MCU that you are using? what are you using together with the "-p" compiler option?

i just skimmed over the manual, within 15 minutes! if you're gonna develop using this tool for a long time, please read and understand the information in the manual.
Title: Re: a/d c18 compiler
Post by: junior000 on January 26, 2008, 11:27:58 AM
yeah,you are probably right.
i did read the manual but skipped the part after seeing the first openadc file.
anyway i will not do the same mistake of not reading the entire manual again:-)

thanks.

regards,
junior
Title: Re: a/d c18 compiler
Post by: rgcustodio on January 26, 2008, 12:45:00 PM
goodluck on your project. hope all goes well!
Title: Re: a/d c18 compiler
Post by: junior000 on January 31, 2008, 03:09:29 AM
ok if i do not configure PORTA as ADC

it is only going to take either 1 or 0????
Title: Re: a/d c18 compiler
Post by: Admin on February 16, 2008, 06:05:50 PM
If its not ADC, then that means its digital - 1 or 0 only ;)