I'm trying to integrate the MCP7940N RTCC into my design. The MCU is the PIC18F67K40 and I'm using I2C to communicate. I created a new starter project to make sure that it works there before I add to my larger design. My IDE is MPLab X v5.4 with MCC 4.02, core v5.0.2. I can't get even this basic project to communicate correctly, I believe the problem is with the timing of the pulses. For this prototype I'm using the Explorer 8 and Mikroe's RTC6 Click board. I started with the RTC Example and I2CSimple Foundation Service. The RTCC Datasheet says it can handle I2C clock up to 400 kHz.
Initialization
...
#pragma config FEXTOSC = OFF // External Oscillator mode Selection bits->Oscillator not enabled
#pragma config RSTOSC = HFINTOSC_64MHZ
...
SSP1CLKPPS = 0x13; //RC3->MSSP1:SCL1;
RC3PPS = 0x19; //RC3->MSSP1:SCL1;
RC5PPS = 0x1A; //RC5->MSSP1:SDA1;
SSP1DATPPS = 0x15; //RC5->MSSP1:SDA1;
...
SSP1STAT = 0x80;
SSP1CON1 = 0x18;
SSP1CON2 = 0x00;
SSP1ADD = 0x03;
SSP1CON1bits.SSPEN = 0;
...
// NOSC HFINTOSC; NDIV 1;
OSCCON1 = 0x60;
// CSWHOLD may proceed; SOSCPWR Low power;
OSCCON3 = 0x00;
// MFOEN disabled; LFOEN disabled; ADOEN disabled; SOSCEN disabled; EXTOEN disabled; HFOEN disabled;
OSCEN = 0x00;
// HFFRQ 64_MHz;
OSCFRQ = 0x08;
// TUN 0;
OSCTUNE = 0x00;
I can open the I2C channel just find, but when I try to read a register on the RTCC it hangs waiting for
PIR3bits.SSP1IF
to be set but it never is. I'm using MCC to generate the RTC and I2C code for me. Thank you.