Other Parts Discussed in Thread: TMS320F2806
Hi everyone, I've got a question. Are all the acknowledgments handeled by the TI uC itself or do I have to implement ACK in my code too. I have tried to establish communication over I2c. Just read some register, thats it. Instead of using interrupts, I am checking if the rxfifo of ic2 contains any bytes or not, but unfortunatelly the whole process doesn't work out as expected. I have used code from the TI example, only the main .c file has been changed as can be seen below. (TMS320F2806)
Thanks,
//initialization before main
void I2CA_Init(void)
{
// Initialize I2C
//0101111(1) = 0x5F
//0101111 = 0x2F
I2caRegs.I2CSAR = 0x005F;//0x0050; // Slave address - EEPROM control code
#if (CPU_FRQ_100MHZ)
I2caRegs.I2CPSC.all = 9; // Prescaler - need 7-12 Mhz on module clk
#endif
#if (CPU_FRQ_60MHZ)
I2caRegs.I2CPSC.all = 6; // Prescaler - need 7-12 Mhz on module clk
#endif
I2caRegs.I2CCLKL = 10; // NOTE: must be non zero
I2caRegs.I2CCLKH = 5; // NOTE: must be non zero
//I2caRegs.I2CIER.all = 0x24; // Enable SCD & ARDY interrupts
I2caRegs.I2CMDR.all = 0x0020; // Take I2C out of reset
// Stop I2C when suspended
I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO
I2caRegs.I2CFFRX.all = 0x2040; // Enable RXFIFO, clear RXFFINT,
return;
}
//******************************************************
//send read request
unsigned int I2CA_ReadData_2(void)
{
if (I2caRegs.I2CMDR.bit.STP == 1)
{
return 1;
}
// Slave address 0101111 plus 1 for read -> 0101111(1) = 0x5F as address
I2caRegs.I2CSAR = i2c_slave_address;
if (I2caRegs.I2CSTR.bit.BB == 1)
{
return 2;
}
I2caRegs.I2CCNT = 1;
I2caRegs.I2CDXR = 0x3F;
I2caRegs.I2CMDR.all = 0x2620; // Send data to setup EEPROM address
var = 2;
return 3;
}
//*******************************************************
main
{
.
.
.
// Endless loop
for(;;)
{
// Check if data in rxbuffer
// Here checkRxfifo is always 0 as declared, means actually no data is ever received by uC
if(I2caRegs.I2CFFRX.bit.RXFFST)
{
checkRxfifo = I2caRegs.I2CDRR;
checkRxfifo_2 = checkRxfifo;
}
if(var == 1)
{
return_readData = I2CA_ReadData_2();
return_readData = return_readData;
}
}
}//main
By the way, do I have to switch from transmitting mode to receiving mode manually (I2CMDR register, bit TRX), or is it done by uC ??