Hi all,
I'm currently working with I2C driver on 6670. The problem I encountered was i couldn't detcct the clock signal on the SCLK pin. First, I put the I2C module in reset
state. Then set the prescaler of the clock and take the module out of reset. What's more, fill the ICCNT and ICSAR registers, set 6670 in TX, master and free mode.
Finally, generate start singal. And the ICDXR with data I want to write to EEPROM. But I couldn't get clock on the corresponding pin. What's wrong with the process of
configuring this module?
The following is part of the program:
CSL_I2cRegs t_I2cRegs;
void i2c_set_opt(void)
{
/*Master mode. The I2C is a master
and generates the serial clock on the SCL pin.*/
t_I2cRegs.ICMDR = 0;
t_I2cRegs.ICMDR = t_I2cRegs.ICMDR|
(1<<CSL_I2C_ICMDR_MST_SHIFT)|
(1<<CSL_I2C_ICMDR_FREE_SHIFT);
t_I2cRegs.ICPSC = 0x319;
t_I2cRegs.ICCLKL = 0x02;
t_I2cRegs.ICCLKH = 0x02;
t_I2cRegs.ICMDR = t_I2cRegs.ICMDR |
(1<<CSL_I2C_ICMDR_IRS_SHIFT);
}
void i2c_tx_fn(UINT8 uwslaveaddr, UINT8* puwdata, UINT16 uwlen)
{
UINT8 i;
t_I2cRegs.ICCNT = uwlen;
t_I2cRegs.ICSAR = uwslaveaddr;
t_I2cRegs.ICMDR |= ICMDR_STT + ICMDR_TRX + ICMDR_MST + ICMDR_IRS + ICMDR_FREE;
delay_cycles(10);
for(i = 0; i < uwlen; i++)
{
t_I2cRegs.ICDXR = puwdata[i];
while((t_I2cRegs.ICSTR & ICSTR_ICXRDY) == 0)
{
;
}
}
delay_cycles(100);
t_I2cRegs.ICMDR |= ICMDR_STP;
/*polling ACK*/
t_I2cRegs.ICSAR = uwslaveaddr;
t_I2cRegs.ICMDR |= ICMDR_STT + ICMDR_TRX + ICMDR_MST + ICMDR_IRS + ICMDR_FREE;
while(t_I2cRegs.ICSTR & ICSTR_NACK)
{
;
}
}
Thanks
Best regards
Nick