dear all,
I am facing a problem with the I2C of the F28335. The DSP is configured as a slave. I do that in my code :
void InitI2CGpio()
{
EALLOW;
/* Enable internal pull-up for the selected pins */
// Pull-ups can be enabled or disabled disabled by the user.
// Comment out other unwanted lines.
GpioCtrlRegs.GPBPUD.bit.GPIO32 = 1; // Disable pull-up for GPIO32 (SDAA)
GpioCtrlRegs.GPBPUD.bit.GPIO33 = 1; // Disnable pull-up for GPIO33 (SCLA)
/* Set qualification for selected pins to asynch only */
// This will select asynch (no qualification) for the selected pins.
// Comment out other unwanted lines.
GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3; // Asynch input GPIO32 (SDAA)
GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3; // Asynch input GPIO33 (SCLA)
/* Configure SCI pins using GPIO regs*/
// This specifies which of the possible GPIO pins will be I2C functional pins.
// Comment out other unwanted lines.
GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1; // Configure GPIO32 for SDAA operation
GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1; // Configure GPIO33 for SCLA operation
EDIS;
}
void InitI2C(void)
{
I2caRegs.I2CMDR.bit.IRS = 0; // put I2C module in reset
// For 30 MHz SYSCLKOUT
I2caRegs.I2CPSC.all = 2; // Prescaler - need 7-12 Mhz on module clk (30/3 = 10MHz)
I2caRegs.I2CIER.all = 0x44; // Enable AAS & ARDY interrupts
// Initialize I2C
I2caRegs.I2COAR = 0x0002; // Slave address du DSP en Slave mode
I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO
I2caRegs.I2CFFRX.all = 0x2060; // Enable RXFIFO, clear RXFFINT,
I2caRegs.I2CMDR.bit.FDF = 0; // free data format is disabled
I2caRegs.I2CMDR.bit.XA = 0; // 7 bits address bit
I2caRegs.I2CMDR.bit.MST = 0; // Slave mode
I2caRegs.I2CMDR.bit.IRS = 1; // Take I2C out of reset
return;
}
That s it for the configuration. Then in main program I do :
EALLOW;
PieVectTable.I2CINT1A = &i2c_int1a_isr;
EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
// Enable I2C interrupt 1 in the PIE: Group 8
PieCtrlRegs.PIEIER8.bit.INTx1 = 1;
// Enable CPU INT8 which is connected to PIE group 8
IER |= M_INT8;
interrupt void i2c_int1a_isr(void) // I2C-A
{
Uint16 IntSource;
// Read interrupt source
IntSource = I2caRegs.I2CISRC.all;
// Read interrupt read as slave
if(IntSource == I2C_AAS_ISRC)
{
I2caRegs.I2CCNT = I2C_NUMBYTES;
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[0];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[1];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[2];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[3];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[4];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[5];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[6];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[7];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[8];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[9];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[10];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[11];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[12];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[13];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[14];
I2caRegs.I2CDXR = CurrentMsgPtr->MsgBuffer[15];
}
else
{
// Generate some error due to invalid interrupt source
asm(" ESTOP0");
}
// Enable future I2C (PIE Group 8) interrupts
PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
}
When I get a read request from the I2C master the data readback by the master are not MsgBuffer[0] to MsgBuffer[15], ther is a shift in the data, and the value of MsgBuffer[0] read by the master is changing from time to time.
Any ideas of what my problem might be ?
Thanks a millions for any idea.