View previous topic :: View next topic |
Author |
Message |
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
I have "undefined indentifier" problem when I comp |
Posted: Tue Jan 24, 2006 3:25 am |
|
|
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
void main() {
int i, value, min, max;
printf("Sampling:");
setup_port_a( ALL_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );
do {
min=255;
max=0;
for(i=0; i<=30; ++i) {
delay_ms(100);
value = Read_ADC();
if(value<min)
min=value;
if(value>max)
max=value;
}
printf("\n\rMin: %2X Max: %2X\n\r",min,max);
} while (TRUE);
}
I am using 3.214
|
|
|
Ttelmah Guest
|
|
Posted: Tue Jan 24, 2006 5:16 am |
|
|
Have a look in your 18F452.h file, and see if the definition is there. The code should compile fine, provided the define is present for 'ALL_ANALOG', so the error suggests that the file has been edited/corrupted, or perhaps the compiler is picking up another file of the same name, that does not contain the required definition. A search for all files called '18F452.h', and a quick check what is in them, should find the problem.
Best Wishes |
|
|
Guest
|
|
Posted: Tue Jan 24, 2006 6:24 am |
|
|
The proper command is
SETUP_ADC_PORTS(ALL_ANALOG); |
|
|
Ttelmah Guest
|
|
Posted: Tue Jan 24, 2006 6:53 am |
|
|
No.
Though I prefer 'SETUP_ADC_PORTS', 'SETUP_PORT_A', has been available as an 'alias' for some time, and predates his compiler version. If you look in the .h file, you will get:
"// ADC Functions: SETUP_ADC(), SETUP_ADC_PORTS() (aka SETUP_PORT_A),"
This is not his problem.
Best Wishes |
|
|
Guest
|
|
Posted: Tue Jan 24, 2006 7:14 am |
|
|
You are correct, I did not know that.
I compiled this code under 3.214 with no errors.
You are correct about it must be something corrupt in the source file. |
|
|
Ttelmah Guest
|
|
Posted: Tue Jan 24, 2006 7:57 am |
|
|
I can't actually understand 'why' they have this alias. It strikes as another way to increase the possible 'permutations' of code that can go wrong....
:-)
My own suspicion, is that there is another file called '18f452.h', probably created by the user for something, which is causing the problem.
Best Wishes |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Tue Jan 24, 2006 10:34 am |
|
|
I just compiled both commands with v3.214 and they came out with the same result.
.................... setup_port_a(all_analog);
0A16: BCF FC1.0
0A18: BCF FC1.1
0A1A: BCF FC1.2
0A1C: BCF FC1.3
.................... setup_adc_ports(all_analog);
0A1E: BCF FC1.0
0A20: BCF FC1.1
0A22: BCF FC1.2
0A24: BCF FC1.3
Ronald |
|
|
|