CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Simple analogue

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
uni_student



Joined: 01 Aug 2007
Posts: 38
Location: AUckland, NEW ZEALAND

View user's profile Send private message Send e-mail MSN Messenger

Simple analogue
PostPosted: Thu Jul 08, 2010 1:21 am     Reply with quote

Hi, trying to follow examples off other threads, but the compiler does not like the following line
Code:
setup_adc_ports(ALL_ANALOG|VSS_VDD);


Unidentified identifier???

Heres full code
Code:
#include <18f1330.h>
#device adc=8 //must be after #include. ADC to return 8 bits
#fuses HS,NOWDT,NOPROTECT, INTRC_IO, BROWNOUT, PUT
#use delay(clock=16000000)
#use rs232(baud=9600, xmit=PIN_B0, rcv=PIN_B1, parity=N, bits=8, ERRORS)
#include <string.h>

void main(){

   unsigned int8  temp;

   setup_adc_ports(ALL_ANALOG|VSS_VDD);
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel(2);
   max=1;
   printf("?f");
   delay_ms(3000);
   printf("?c0");
   while (TRUE){
      temp= read_adc();
      /*if(temp>max){
         max=temp;
      }
      putc(max);*/
      printf("?y1");
      printf("?l");        //clear cursor line
      printf("?x06");
      printf(temp);
      delay_ms(250);
   }
}


Any help appreciated
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Jul 08, 2010 2:22 am     Reply with quote

The parameters you can use for setup_adc_ports() are different for many of the PIC models. Read the file 18f1330.h for what is allowed in your chip.

Always post your compiler version number.
uni_student



Joined: 01 Aug 2007
Posts: 38
Location: AUckland, NEW ZEALAND

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Thu Jul 08, 2010 4:00 am     Reply with quote

Compiler Version 3.249

18f1330 Header file makes no reference to setup_adc_ports??? Confused :(
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Thu Jul 08, 2010 4:05 am     Reply with quote

ckielstra was refering to ALL_ANALOG, VSS_VDD and ADC_CLOCK_INTERNAL.

My version of CCS 18F1330.h file does have these defined. Check yours!
uni_student



Joined: 01 Aug 2007
Posts: 38
Location: AUckland, NEW ZEALAND

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Thu Jul 08, 2010 3:19 pm     Reply with quote

Yeah i checked over about a million times and no constants for setup_adc_ports are evident. Checked 18f1230 aswell and nothing, Tried a few other header files and they all have constants, dont know why its just them two. Reloaded the ccs cd and still nothing. Very confused now.... Has this got anything to do with my compiler version??? Or am i missing the #defines in my header files?? Can anyone post just the #define 's just for setup_adc_ports???

Also anything wrong with the code above???
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 08, 2010 3:33 pm     Reply with quote

I installed vs. 3.249 and looked at 18F1330.h and you're right, it is
missing some of the constants for the A/D. That's a bug.

Here's the missing part. Add this to the .h file and see if it now works.
(This code is from vs. 4.109).
Code:

// Constants used in SETUP_ADC_PORTS() are:

#define ALL_ANALOG   0x0        // A0 A1 A4 A6
#define AN1_AN2_AN3     1       // A1 A4 A6
#define AN0_AN2_AN3     2       // A0 A4 A6
#define AN2_AN3         3       // A4 A6
#define AN0_AN1_AN3     4       // A0 A1 A6
#define AN1_AN3         5       // A1 A6
#define AN0_AN3         6       // A0 A6
#define AN3             7       // A6
#define AN0_AN1_AN2     8       // A0 A1 A4
#define AN1_AN2         9       // A1 A4
#define AN0_AN2         0xa     // A0 A4
#define AN2             0xb     // A4
#define AN0_AN1         0xc     // A0 A1
#define AN1             0xd     // A1
#define AN0             0xe     // A0
#define NO_ANALOGS      0xf       // None


// One of the following may be OR'ed in with the above using |
#define VSS_VDD              0x00        //| Range 0-Vdd
#define VSS_VREF             0x10        //| Range 0-Vref
uni_student



Joined: 01 Aug 2007
Posts: 38
Location: AUckland, NEW ZEALAND

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Thu Jul 08, 2010 5:43 pm     Reply with quote

WOW!! I found a bug in CCS, thats just made my day! Cheers PCM all working now!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 08, 2010 5:51 pm     Reply with quote

Well, it's a bug that was in their program that generates the .h files. They
don't make the .h files by hand. This was in March 2006 (vs. 3.249).
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group