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.

CCS/TMS320F28035: questions about the I2C slave setting on TMS320F28035

Part Number: TMS320F28035
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

hi

   I have set an I2C slave on the TMS320F28035, but it doesn`t work. The master cannot find a slave on the bus. And, I did not find the relevant examples. I don't know if my program structure is correct. So, I am asking for help in the forum.

Thanks

the mian function:

/*
* main.c
*/
#include "DSP28x_Project.h"
#include "DSP2803x_I2c.h"
#include "DSP2803x_I2c_defines.h"
#include <math.h>


#define I2C_slave_addr 0x08
#define LED_ON GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1;
#define LED_OFF GpioDataRegs.GPBSET.bit.GPIO34 = 1;
#define LED_BLINK GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1;
struct I2C_REGS I2c_slave;

int read=0;
int count=0;


void I2C_Slave_Init(void);
int I2C_Slave_read(void);

int main(void)
{
InitSysCtrl();
InitGpio();

InitI2CGpio();

I2C_Slave_Init();

DINT;


InitPieCtrl();

IER = 0x0000;
IFR = 0x0000;

InitPieVectTable();


// InitPeripherals();

while(1)
{
read=I2C_Slave_read();
if (read == 0x0001)
{
LED_OFF;
}
else
{
LED_ON;
}
}
}

void I2C_Slave_Init(void)
{
I2c_slave.I2COAR = 0x0010; // Set Own Adress
I2c_slave.I2CMDR.all = 0x0000;

I2c_slave.I2CPSC.all = 19; // Prescaler - need 7-12 Mhz on module clk
I2c_slave.I2CCLKL = 10; // NOTE: must be non zero
I2c_slave.I2CCLKH = 5; // NOTE: must be non zero
I2c_slave.I2CIER.all = 0x0; // disable SCD & ARDY __interrupts

I2c_slave.I2CFFTX.all = 0x0000; // Enable FIFO mode and TXFIFO
I2c_slave.I2CFFRX.all = 0x0000; // Enable RXFIFO, clear RXFFINT,

I2c_slave.I2CMDR.all = 0x0020; // I2C Slave, Free, release from reset
return;
}

int I2C_Slave_read(void)
{
int i;
I2c_slave.I2CCNT=1;
// I2c_slave.I2COAR=I2C_slave_addr;
// I2c_slave.I2CSAR=I2C_slave_addr;
// I2c_slave.I2CMDR.all=0x6c20;
i = I2c_slave.I2CDRR & 0x00FF;//I2CDRR is a 16 bit register,
return i;
// receivedata[0]=I2c_slave.I2CDRR;
}

  • hi ,

    "The master cannot find a slave on the bus. " What do you mean ? Is it data is not being received by slave?

    You could refer to receive/slave section in the loopback example though for a different device for an idea on the sequence.

    C2000Ware\driverlib\f2837xd\examples\cpu1\i2c\i2c_ex1_loopback.c

    Can you use enable interrupts mode or poll on flags to see if the data is received after which read the data?

    Another way would be to use FIFOs so sets of data can be transferred at a time.

    Regards.

  • the slave cannot receive the data. I will try your suggestions.

    thank you very much. :)