So I've been tackling this problem with integrating I2C functionality into my code, which is documented here on StackOverflow: https://stackoverflow.com/questions/25224541/receiving-undefined-symbols-error-with-xc8-concerning-plib-i2c-functions
TLDR: I2C plib didn't work because PIC12 is not a PIC18, I sorted it out by copying the sources and changing the relevant regs, hoping that it would work...
...and now I've run into another stumbling block. When the program tries to open an I2C connection, it seemingly remains stuck on the StartI2C()
method which sets SSPCON2bits.SEN
high and as it is so commented in the copied sources waits for it to "automatically be cleared by hardware". I'm running this in MPLABX's simulator and this is where its stuck, I have a PICkit3, but it tells me it can't breakpoint anywhere, so thats useless for actually debugging the part, so I'm assuming whats happening in the simulator is exactly whats happening on the part (which is a poor assumption, but I've got nothing else to really rely on right now).
So I'm guessing theres two questions here, should the ported code be compatible as written since it was written for the MSSP module that is probably copied around in many of their parts?
and
If the SSPCON2bits.SEN
bit is supposed to be cleared by hardware automatically, why isn't it being cleared?
All of the relevant code concerning my wrappers and setup are in the linked StackOverflow question. All the relevant code concerning Microchip's I2C plib drivers are located in any install of MPLABX with XC8 under /path/to/xc8/install/directory/version/sources/pic18/plib/i2c/i2c_*.c
with the header file being inside /path/to/xc8/install/directory/version/include/plib/i2c.h
.
UPDATE: All the code
- i2c.h - Microchip code modified for PIC12LF1552
- pastebin.com/wLUJ0xpH
- i2c.c - Microchip code modified for PIC12LF1552
- pastebin.com/CTEyZETf
- plur_i2c.h - My header file for wrapping Microchip's I2C functions
- pastebin.com/HvphrFC8
- plur_i2c.c - My source file for wrapping Microchip's I2C functions
- pastebin.com/F95Kjrzj
- main.c - Main body of code to be executed (not complete)
- pastebin.com/NyTkP2pU