Tool/software: Code Composer Studio
I'm using TI USB adapter interface connect to 28035 evm board.
Is it possible to control i2c ack or i2c tx latency outside of interrupt.
I'd like to collection data inside the interrupt and make some operation outside the interrupt.
So that the interrupt won't necessary being blocked while processing data.
I thought I could ignore the tx interrupt until the processing done.
With small latenty it seems work fine, but longer latency...
I wonder if I could control the ack or response time to master device, so that I can have enough time to
parse the data.
unsigned char InBuffer[BUFSIZ];
unsigned char OutBuffer[BUFSIZ];
int InBufIndex = 0;
int InBufPos = 0;
int OutBufIndex = 0;
int OutBufPos = 0;
void main(void)
{
InitSysCtrl();
InitGpio();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.TINT0 = &cpu_timer0_isr;
PieVectTable.I2CINT1A = &I2CSlaveInt1a;
InitI2C();
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, 60, 10000);
CpuTimer0Regs.TCR.all = 0x4001;
IER |= M_INT1;
IER |= M_INT8;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
PieCtrlRegs.PIEIER8.bit.INTx1 = 1;
EINT;
ERTM;
for (;;) {
/* check data for every 100ms or 500ms */
I2CDataHandler();
}
}
void InitI2C(void)
{
I2caRegs.I2COAR = 0x50;
I2caRegs.I2CPSC.all = 9;
I2caRegs.I2CCLKL = 10;
I2caRegs.I2CCLKH = 5;
I2caRegs.I2CIER.all = 0x7f;
I2caRegs.I2CMDR.bit.IRS = 1;
I2caRegs.I2CMDR.bit.RM = 0;
}
interrupt void I2CSlaveInt1a(void)
{
Uint16 intSrc = I2caRegs.I2CISRC.bit.INTCODE;
switch (intSrc) {
case I2C_NO_ISRC:
break;
case I2C_ARB_ISRC:
break;
case I2C_NACK_ISRC:
break;
case I2C_ARDY_ISRC:
info.ardyCount++;
if (I2caRegs.I2CSTR.bit.NACK == 1) {
I2caRegs.I2CMDR.bit.STP = 1;
I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT;
}
break;
case I2C_RX_ISRC:
/* receive data in the interrupt */
InBuffer[InBufPos++] = I2caRegs.I2CDRR;
break;
case I2C_TX_ISRC:
/* transmit the rest of the data in the interrupt */
if (OutBufIndex < OutBufPos) {
I2caRegs.I2CDXR = OutBuffer[OutBufIndex++];
OutBufIndex &= 0xff;
}
break;
case I2C_SCD_ISRC:
break;
case I2C_AAS_ISRC:
break;
}
PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
}
void I2CDataHandler(void)
{
OutBuffer[0] = 0x22;
OutBuffer[1] = 0x23;
OutBufPos = 2;
OutBufIndex = 0;
I2caRegs.I2CDXR = OutBuffer[0];
OutBufIndex++;
}