View previous topic :: View next topic |
Author |
Message |
uni_student
Joined: 01 Aug 2007 Posts: 38 Location: AUckland, NEW ZEALAND
|
Simple analogue |
Posted: Thu Jul 08, 2010 1:21 am |
|
|
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
|
|
Posted: Thu Jul 08, 2010 2:22 am |
|
|
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
|
|
Posted: Thu Jul 08, 2010 4:00 am |
|
|
Compiler Version 3.249
18f1330 Header file makes no reference to setup_adc_ports??? Confused :( |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Thu Jul 08, 2010 4:05 am |
|
|
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
|
|
Posted: Thu Jul 08, 2010 3:19 pm |
|
|
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
|
|
Posted: Thu Jul 08, 2010 3:33 pm |
|
|
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
|
|
Posted: Thu Jul 08, 2010 5:43 pm |
|
|
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
|
|
Posted: Thu Jul 08, 2010 5:51 pm |
|
|
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). |
|
|
|