Hi,
My chip is omapl_137,i'd like to use I2c in Master Receiver mode,My code is like following
void I2C_init()
{
//Prescaled module clock = I2C input clock frequency 24M/(IPSC + 1)
//Prescaled module clock between 6.7 and 13.3 MHz.
I2cRegs_0->ICMDR = 0; //reset
I2cRegs_0->ICMDR = 0;//clean ICMDR
I2cRegs_0->ICMDR |= CSL_I2C_ICMDR_MST_MASK;//master mode
I2cRegs_0->ICSAR |=0x51; // set data to I2C device
I2cRegs_0->ICPSC |= 0x01; //12M
//I2C clock frequency 1M
I2cRegs_0->ICCLKH = 0x06;
I2cRegs_0->ICCLKL = 0x06;
I2cRegs_0->ICSTR = I2cRegs_0->ICSTR;//clean ICSTR ?
//clean all interrupt
while(I2cRegs_0->ICIVR != 0)
{
}
I2cRegs_0->ICIMR |= CSL_I2C_ICIMR_ICRRDY_MASK; //close all interrupt;
I2cRegs_0->ICIMR |= CSL_I2C_ICIMR_ICXRDY_MASK;
// I2cRegs_0->ICOAR |=0x51; // set data to I2C device
I2cRegs_0->ICMDR |= CSL_I2C_ICMDR_IRS_MASK;//enable I2C
}
void I2C_Write(Uint32 src,Uint16 dst, Uint32 lenth)
{
Uint32 temp_src = src;
Uint32 cnt = 0;
Uint32 i = 0;
I2cRegs_0->ICIMR = 0; //close all interrupt;
I2cRegs_0->ICCNT = lenth & I2c_BUFFER_MAXLENGTH; //set Write lenth
I2cRegs_0->ICMDR |= CSL_I2C_ICMDR_TRX_MASK;//write
while((I2cRegs_0->ICSTR & CSL_I2C_ICSTR_BB_MASK)!= 0)
{
}
I2cRegs_0->ICMDR |= CSL_I2C_ICMDR_STT_MASK; // begin
while(i<2)
{
if ((I2cRegs_0->ICSTR & CSL_I2C_ICSTR_ICXRDY_MASK) != 0)
{
I2cRegs_0->ICDXR = (dst >> i*8);
i++;
}
}
while(cnt < lenth)
{
if ((I2cRegs_0->ICSTR & CSL_I2C_ICSTR_ICXRDY_MASK) != 0)
{
I2cRegs_0->ICDXR = 0x66;
++(temp_src);
++cnt;
}
}
I2cRegs_0->ICMDR |= CSL_I2C_ICMDR_STP_MASK; // end
}
void I2C_Read(Uint16 src,Uint32 dst, Uint32 lenth)
{
Uint32 temp_src = dst;
Uint32 cnt = 0;
Uint32 i = 0;
I2cRegs_0->ICIMR = 0; //close all interrupt;
I2cRegs_0->ICCNT = lenth & I2c_BUFFER_MAXLENGTH; //set Read lenth
I2cRegs_0->ICMDR &= ~CSL_I2C_ICMDR_TRX_MASK;//read enable
I2cRegs_0->ICMDR |= CSL_I2C_ICMDR_STT_MASK; // begin
while(i<2)
{
if ((I2cRegs_0->ICSTR & CSL_I2C_ICSTR_ICXRDY_MASK) != 0)
{
I2cRegs_0->ICDXR = (Uint8)(src >> i*8);
i++;
}
}
while(cnt < lenth)
{
if ((I2cRegs_0->ICSTR & CSL_I2C_ICIMR_ICRRDY_MASK) != 0)
{
*(Uint8*)(dst) = I2cRegs_0->ICDXR ;
++(temp_src);
++cnt;
}
}
I2cRegs_0->ICMDR |= CSL_I2C_ICMDR_STP_MASK; // end
}
I think,i have exactly follwed the insruction of operation of TMS320C674x/OMAP-L1x Processor Inter-Integrated Circuit (I2C) Module User guide. And,i have check my pinmux is right,but my code is not work,can you give me some help? Is there any exmaple of how to use I2C in Master Receiver mode?