Hi Guys
I have a issue with getting my I2C bus to transmit data on the PIC24FJ128GB210, no clock or data is present its probably a configuration issue that I haven't considered. I checked the datasheet and all seems okay from what I read. I didn't check the errata for the PIC24FJ128GB210 cannot seem to find it.
Here are the code snippets.
// Clock is 16mhz, fcy = 8mhz
// make TRISA14, TRISA14 inputs.
TRISAbits.TRISA14 = 1;
TRISAbits.TRISA15 = 1;
// map SDI2 AND SCK2
PPSUnLock;
iPPSInput( IN_FN_PPS_SDI2, IN_PIN_PPS_RPI35 );
iPPSInput( IN_FN_PPS_SCK2IN, IN_PIN_PPS_RPI36 );
PPSLock;
// Im sending test data as a test in the loop.
void main()
{
__delay_us(100);
// send data
data_send_i2c();
}
void data_send_i2c(void)
{
// 1) Master sends STart //
CloseI2C2(); // Disable I2C1 mdoule if enabled previously
unsigned int config1 = (I2C_ON | I2C_7BIT_ADD );
unsigned int config2 = 78; // I2CxBRG 100kHz bus with 16MHz oscillator
OpenI2C2(config1,config2); // configure I2C1
IdleI2C2();
// 1) Master sends STart
StartI2C2();
while(I2C2CONbits.SEN ); // Wait till Start sequence is completed
MI2C2_Clear_Intr_Status_Bit; // Clear interrupt flag
// 2) Master sends Slave ADdress with Write bit set //
MasterWriteI2C2( 0xff ); //Write Slave address and set master for transmission
while(I2C2STATbits.TBF); //Wait till address is transmitted
while(!IFS3bits.MI2C2IF); //Wait for ninth clock cycle
// dont ask the slave for any ack this is a test ? see anything on the scope yet???
}
This issue was keeping me busy all weekend with no luck. Please help.