Hi, can you provide a code snippet to explain i2c slave operation in 28035 device?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi, can you provide a code snippet to explain i2c slave operation in 28035 device?
Sai,
We don't have I2C slave example for F28035 device. But, we have a slave example in F2838x device (which uses driverlib). You can apply the logic and code it in bit-field. This reply was in the original post and it still applies.
The only slave example we have currently is for the F2838x (i2c_ex3_external_loopback from C2000Ware 2.00.00.02), but it's written with a driverlib API, so it may be a bit of a challenge to translate it back to the bit-field struct header files that F28035 uses. Might help to look at it though.
You can also try searching the forum to see if someone else has shared some slave code.
Whitney
Regards,
Manoj
The example code uses driver lib and it is written for 2838x series. Can you please post a very simple slave code example for 28035 which explains i2c interrupts required, slave mode - tx or rx and detect whether last byte was address or data.
I don't have readymade code to share with you. I do know that example I pointed to you belongs to 2838x series. But, I2C module available in F2838x and F2803x are pretty much the same. So, the register configurations are pretty much the same. So, you should be able to adapt the driverlib code to headerfile approach.
Regards,
Manoj
void init_i2c_slave(void)
{
I2caRegs.I2COAR = 0x50;
I2caRegs.I2CIER.bit.XRDY = 1;
I2caRegs.I2CIER.bit.RRDY = 1;
I2caRegs.I2CIER.bit.AAS = 1;
I2caRegs.I2CMDR.bit.MST = 0;
I2caRegs.I2CMDR.bit.IRS = 1;
}
__interrupt void isr_i2c(void)
{
Uint32 int_code = 0;
int_code = I2caRegs.I2CISRC.bit.INTCODE;
if(int_code == 0b100) //receive ready interrupt
{
i2c_rx_data[i2c_rx_index++] = I2caRegs.I2CDRR;
I2caRegs.I2CSTR.bit.RRDY = 1;
}
if(int_code == 0b101) //transmit ready interrupt
{
I2caRegs.I2CDXR = i2c_tx_data[i2c_tx_index++];
}
if(int_code == 0b111) //addressed as slave
{
i2c_rx_index = 0;
i2c_tx_index = 0;
}
// reset interrupt flag
PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
}