I2C master not generating start condition, or any condition...
I have several I2C master designs using the 16F18326. I created my own I2C write/read functions using registers (no interrupts). Now I'm using 16F18446 with the same write/read functions but can't seem to generate a start function.
I do this:
SSP2CON2bits.SEN = 1; /* Begin I2C start */
And then poll for the flag to get set:
while(SSP2IF == 0);
But nothing happens and my watchdog expires.
My pin_manager function initializes things like this:
SSP2DATPPS = 0x0D; //RB5->MSSP2:SDA2;
RB7PPS = 0x15; //RB7->MSSP2:SCL2;
RB5PPS = 0x16; //RB5->MSSP2:SDA2;
RC4PPS = 0x18; //RC4->NCO1:NCO1OUT;
SSP2CLKPPS = 0x0F; //RB7->MSSP2:SCL2;
There is one thing that seems weird, and that is that the datasheet in Table 16-3 does not actually list 0x15 and 0x16 as valid settings for the PPS output signal registers!? This code was generated from MCC, so who should I trust more?
And my I2C initialization function does this:
/* I2C baud rate target is 100kHz - use equation per pg 364 of datasheet */
/* i2c_clk_period = (SSPxADD<7:0> + 1)*4 / Fosc */
SSP2ADD = 0x3; /*TODO: understand how exactly this changes I2C frequency */
PIE3bits.SSP2IE = 1; /* set as I2C master */
PIR3bits.SSP2IF = 0;
SSP2STAT = 0x00;
SSP2CON1 = 0x28;
SSP2CON2 = 0x00;
PIE3bits.SSP2IE = 1;
And finally in main.c, I enable interrupts (even though I'm not using them) because it seemed that I needed to do that to get the interrupt flag register to actually post flags so I could poll it:
GIE = 1;
PEIE = 1;
Thanks in advance for any tips, its been a few hours now and am stumped.