Thanks Brent. I'm looking through some of the files it's created and=20 the function nams seem to be self-explanatory, though I wonder if I'll=20 have to decipher their code to figure out details. Time is of the essence, but I think I'll risk it. Cheers, -Neil. On 9/16/2018 7:44 PM, Brent Brown wrote: > Hi Neil, > > Have recently gone down the same track, 18LF46K22, MCC & XC8. It took som= e > time/effort to figure things out, but between the .c and .h files there i= s kindof enough > info to figure out how they work. I agree it could be easier. After some = trial & error it > started to fall into place somewhat and I could appreciate that MCC was a= ctually > being helpful. Examples: > > result =3D ADC_GetConversion(6); // Get ADC result, channel 6 > > #define MCP23017 0x20 // I2C address of MCP23017 16bit I/O expander > unsigned char somedata[12] =3D { 0x00, // Starting from register address = 0 > 0xFF, // IODIRA - Direction A all inputs > 0x01, // IODIRB - Direction B one input > 0x00, // IPOLA - Input polarity A > 0x00, // IPOLB - Input polarity B > 0xFF, // GPINTENA - Interrupt on change A, 8 inputs > 0x01, // GPINTENB - Interrupt on change B, 1 input > 0xFF, // DEFVALA - Default value compare A > 0xFF, // DEFVALB - Default value compare B > 0xFF, // INTCONA - Interrupt A use DEFVAL > 0xFF, // INTCONB - Interrupt B use DEFVAL > 0x40 }; // IOCON - INT pins OR'ed > I2C1_MasterWrite(somedata, 12, MCP23017, &I2C_Wflag); // Send 12 bytes of > data to I2C chip to initialize > > command =3D 0x12; // Request key status (inputs) > length =3D 1; // from I2C port expander chip > I2C1_MasterWrite(&command, length, MCP23017, &I2C_Wflag); > __delay_us(10); > I2C1_MasterRead(I2Cdata, 2, MCP23017, &I2C_Rflag); // Returned data is in > I2Cdata[0] and I2Cdata[1] > > > On 16 Sep 2018 at 18:36, Neil wrote: > >> I need to add I2C functionality to existing code (18F25K42, XC8) and >> some libraries for this might be nice for a change of individually >> setting registers. >> >> However, it seems that Mchip's direction on this is to install MCC, then >> let MCC build the code framework their way (similar to PIC32 code >> w/Harmony). >> Assuming I'm willing to do that (not sure I am yet), I installed the MCC >> plugin, but can't find API docs. Google results indicate that there is >> some documentation in the code, but there really isn't. For example, I >> have the ADC module setup, but there's nothing that tells me what to >> call to select and sample a channel, how to determine completion and >> extract the result, etc. >> >> Alternatively, can I just include and access the MCC libraries directly >> from my own code? If so, where is MCC even installed? >> >> Cheers, >> -Neil. >> >> >> --=20 >> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .