Question

I'm trying to compile code for a PIC16F77 microcontroller using the Hi-Tech C compiler.

The code below gives an error on the last line in the snippet below. The errors are:

Error   [195] C:\...\.c; 8.1 expression syntax
Error   [201] C:\...\.c; 8.8 taking the address of this object is illegal

I have narrowed the problem down to the following:

#define TEST1       0x01;
#define TEST2       0x80;
#define TEST3       (TEST1 | TEST2)

// in main():
ADCON0 = TEST1; // works
ADCON0 = TEST2; // works
ADCON0 = TEST3; // compile error

(ADCON0 is the 8-bit register which has flags for controlling the ADC.)

Any idea what's wrong with the code?

Thanks

Était-ce utile?

La solution

Remove the semi-colons from your defines of TEST1 and TEST2, cause with them, TEST3 expands to (0x01; | 0x80;)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top