2020/11/25 18:28:39
MPLabX v5.40
XC8 2.20
Pack PIC18F-Q_DFP 1.8.154
MCC plugin v4.0.2
Issue 1:  MCC fails to configure I2C1CON2 correctly after change
1/ Add an I2C1 peripheral.
Set the pins in pin manager and use internal pull-ups.
Generate Code.
I2C1CON2 = 0x18
2/ Edit the peripheral and turn on fast mode.
Generate Code.
3/ Edit the peripheral and turn off fast mode.
Generate Code.
I2C1CON2 = 0x00 // 0 is incorrect it should be 0x18
Issue 2: Interrupt driven I2C gets stuck in never ending interrupt loop.
Take some working MCC I2C polling mode code and enable interrupts on the I2C peripheral in MCC.
On calling I2C1_Open, the code gets stuck in a never ending interrupt loop as I2C1PIRbits.PCIF keeps getting set due to I2C1_MasterResetBus call in I2C1_DO_RESET.  It seems that disabling and enabling the I2C peripheral causes the PCIF to be set again, just after the enable code.  Commenting out the enable/disable in this code makes everything work fine.
Is it possible this is a silicon bug?
static inline void I2C1_MasterResetBus(void)
    //Disable I2C1
    I2C1CON0bits.EN = 0;
    //Set Clear Buffer Flag
    I2C1STAT1bits.CLRBF = 1;
    //Enable I2C1
    I2C1CON0bits.EN = 1;

© 2021 APG vNext Commercial Version 4.5

Use My Existing Forum Account