Hello:
I have a code implementation for reading UID and write/read data for MIFARE CLASSIC tags that works fine using CLRC663 and SPI communication.
I am trying to use it with I2C communication but i have problems with the CLRC663. It is locking the bus after readings .
I can write data to CLRC663's registers and i receive I2C AKCs ( even i can perform NFC TX transmissions), but the CLRC663 breaks the bus after reading operations. CLRC663 sends a byte of data, but then it indefinitely holds SDA Low (SCL keeps high) and the only way i have to unlock the bus is manually sending pulses through SCL (revive_I2C() function provided or with a writing call).
I am following the information about the protocol provided in the datasheet of CLRC663 (8.4.4.8 I2C-register read access part).
I have checked the data with the osciloscope and I cut off microcontroler'SDA line in order to check which system is locking the bus. I also have tested the I2C communicaton with another devices and the bus work fine.
Could you help me? What could the error be?
CODE EXAMPLE
********************************************************
void revive_I2C()
{
if (input(I2C_SCL) && !input(I2C_SDA)) //IF I2C LOCKED
{
for (int i = 0; i < 9; i++)
{
output_low(I2C_SCL);
delay_us(10);
output_float(I2C_SCL);
delay_us(10);
}
i2c_stop();
}
}
void main()
{
int value;
#define I2C_CLR663_DIR_R 0b01010001
#define I2C_CLR663_DIR_W 0b01010000
i2c_start();
i2c_write(I2C_CLR663_DIR_W);
i2c_write(CLRC663_REG_STATUS);
i2c_stop();
i2c_start();
i2c_write(I2C_CLR663_DIR_R);
value = i2c_read();
i2c_stop();
printf("\n Readed: %x", value);
while(1)
{;}
}
***************************************************
The hardware i am using is a PIC microcontroler (with CCS) connected to a custom PCB with a CLRC66303 IC and an antenna. The I2C pullups are 1K resistors. IFx and IFSELx pin connections configured for I2C according with the CLRC663 datasheet. I tried severeal CLRC663 from several providers.
The IF/IFSEL connections are the following:
IF0 - GND IFSEL0 - 3.3V
IF1 - SCL IFSEL1 - GND
IF2 - GND
IF3 - SDA