It depends on what you mean by "support". Just because there may not be a canned library doesn't mean you can't use the peripheral.
The XC compilers offer direct access to the special function registers and interrupt capabilities of the target device. You can just as easily configure the I2C peripherals and handling routines in C as you could in assembly language. The device datasheet will include all the details for setting up these peripherals. Just read the datasheet, write the necessary values to the necessary SFRs and poll/interrupt as needed.
(It's often easier to code this way, as you're not reliant on closed-source libraries that may not do exactly what the advertise.)
This is a C problem.
period periods[3] = {p1, p2, p3};
is invalid in C, as p1
, p2
& p3
are struct variables, and not constants known at compile-time, therefore you cannot use them as initializers.
You may use macros to substitute the same constant values into p1
, p2
, p3
and periods[3]
so that you don't have to duplicate the values:
#define P1 {1, {0, 0, 0, 1, 1, 14}, {20, 0, 0, 1, 1, 14}, 1}
#define P2 {1, {21, 0, 0, 1, 1, 14}, {50, 0, 0, 1, 1, 14}, 1}
#define P3 {1, {51, 0, 0, 1, 1, 14}, {59, 0, 0, 1, 1, 14}, 1}
period p1 = P1;
period p2 = P2;
period p3 = P3;
period periods[3] = { P1, P2, P3 };
Or you may simply avoid initializers altogether, and use explicit statements at the beginning of your program to initialize these arrays.
Best Answer
As Roger says, use XC8. It's the newer compiler.
The C18 compiler is obsolete and it won't support any newer devices.
Another disadvantage of C18 is that it only supports the PIC18 family of microcontrollers as opposed to the XC8, which supports all the 8-bit PIC microcontrollers: PIC10, PIC12, PIC16, PIC18.
I'd also argue that XC8 (which is based on the HI-TECH C Compiler) is a tad easier to use than C18. Just take a look at how you would declare an ISR in both compilers:
C18:
vs XC8: