Part Number: TMS320F28377S
Other Parts Discussed in Thread: CONTROLSUITE
Tool/software: Code Composer Studio
Dear All,
I am working on TMS320F28377S processor and I am new to this. I am interfacing ee prom AT24C16 with processor. I see the examples available with control suit which uses interrupt. But I want to develop simple function without using interrupt. This is the function I write to I2C, and they are not working. My previous experience is on ATMEGA controller, so please any one can help for same.
Thank's
void I2CA_Init(void)
{
GPIO_SetupPinMux(32, GPIO_MUX_CPU1, 1);
GPIO_SetupPinMux(33, GPIO_MUX_CPU1, 1);
I2caRegs.I2CPSC.all = 6; // Pre scaler - need 7-12 Mhz on module clk
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
I2caRegs.I2CMDR.bit.RM=0; // Disable repeated transmit condition
I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO
I2caRegs.I2CFFRX.all = 0x2040; // Enable RXFIFO, clear RXFFINT,
return;
}
void write_i2c(unsigned char address,unsigned char data)
{
while(I2caRegs.I2CMDR.bit.STP == 1) //wait for i2c bus to end any prrevious communication
I2caRegs.I2CSAR.all=address;
while(I2caRegs.I2CSTR.bit.BB == 1); //wait for to bus free
I2caRegs.I2CDXR.all =0x00; //write address on which data is to be put
I2caRegs.I2CDXR.all =data;
return;
}
unsigned char read_i2c(unsigned char address)
{
unsigned char data;
while(I2caRegs.I2CMDR.bit.STP == 1) //wait for i2c bus to end any prrevious communication
I2caRegs.I2CSAR.all=address;
while(I2caRegs.I2CSTR.bit.BB == 1); //wait for to bus free
data=I2caRegs.I2CDRR.all; //read data form
return data;
}
void start_condition(void)
{
I2caRegs.I2CMDR.bit.STT=1; //send start condition
while(I2caRegs.I2CSTR.bit.BB == 1); //wait for to bus free
return;
}
void stop_condition(void)
{
I2caRegs.I2CMDR.bit.STP=1; //send stop condition
while(I2caRegs.I2CSTR.bit.BB == 1); //wait for to bus free
return;
}