go_away

Author Topic: a/d c18 compiler  (Read 7712 times)

0 Members and 1 Guest are viewing this topic.

Offline junior000Topic starter

  • Full Member
  • ***
  • Posts: 59
  • Helpful? 0
a/d c18 compiler
« 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
view my tutorials at


www.myfirstbot.blogspot.com

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: a/d c18 compiler
« Reply #1 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

Offline rgcustodio

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 0
  • Use "Search" and ye might find answers!
Re: a/d c18 compiler
« Reply #2 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.
« Last Edit: January 26, 2008, 08:30:09 AM by rgcustodio »
The best thing one can do when it's raining is to let it rain. - H. W. Longfellow

understanding is the path to enlightenment

Offline junior000Topic starter

  • Full Member
  • ***
  • Posts: 59
  • Helpful? 0
Re: a/d c18 compiler
« Reply #3 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
view my tutorials at


www.myfirstbot.blogspot.com

Offline rgcustodio

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 0
  • Use "Search" and ye might find answers!
Re: a/d c18 compiler
« Reply #4 on: January 26, 2008, 12:45:00 PM »
goodluck on your project. hope all goes well!
The best thing one can do when it's raining is to let it rain. - H. W. Longfellow

understanding is the path to enlightenment

Offline junior000Topic starter

  • Full Member
  • ***
  • Posts: 59
  • Helpful? 0
Re: a/d c18 compiler
« Reply #5 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????
view my tutorials at


www.myfirstbot.blogspot.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,665
  • Helpful? 169
    • Society of Robots
Re: a/d c18 compiler
« Reply #6 on: February 16, 2008, 06:05:50 PM »
If its not ADC, then that means its digital - 1 or 0 only ;)

 


Get Your Ad Here