Go Down

Topic: I2C Daisy Chain fails - NFC devices (Read 173 times) previous topic - next topic

Ehsani

Dec 18, 2018, 05:20 pm Last Edit: Dec 20, 2018, 04:43 pm by Ehsani
Dear readers,
My setup includes Arduino Nano as I2C master and 4 four NFC devices as slaves. I can successfully read from NFC tags and write to them with no problem in addressing NFCs. The problem appears when I try to turn antenna of one NFC off or on. It simply makes antennas on all 4 NFCs change status at the same time. I can confirm that both by probing the radio emission of the antenna at 13.56MHz, which is working frequency of NFCs, and also reading related control register. Changing TxControlReg on one NFC, at one address, changes TxControlReg registers on other addresses too.
Keep in mind that other operations such as read and write flawlessly is done at desired address. For double check I examined I2C bus signals and confirmed that I send antenna on/off commands only to one address. Seems like these commands are broadcastet instead of addressing one single NFC.
NFC chips are mrfc522. Attached you can find edited version of MFRC522_I2C which I use.
Best regards,
Ehsan    

pylon

You just posted the library code. Where is the your code which is not working as expected?

Ehsani

#2
Dec 20, 2018, 04:33 pm Last Edit: Dec 20, 2018, 04:47 pm by Ehsani
Hi,
The relevant piece of code is as follows. data array is received from UART and is sent only once to one address in each try:

  MFRC522 mfrc522(data[1], 0); //data[1] contains I2C address of the NFC
  Serial.print(", Change antenna status: ");
  Serial.print(data[2]);
  if (data[2] == 1) //You can guess what data[2] includes
  {
    mfrc522.PCD_AntennaOn();
    mfrc522.PCD_SetAntennaGain(data[3]);
    Serial.print("Antenna gain set to ");
    Serial.print(data[3]);
  }
  else
  {
    mfrc522.PCD_AntennaOff();
  }


I have attached all project files to the main post.
A new test shows that I cannot set AntennaGain either. Even though the related register is written to, the antenna gain doesn't show any interest to change. Make sure to download all attached files again, since they are updated.

pylon

Code: [Select]
const byte TEST4 = A4;
  pinMode(TEST4, OUTPUT);


A4 is internally connected to SDA so you must not use that pin if you're using I2C.

Ehsani

True.
Fixed the bug, but the problem still exists.

pylon

I2C address 0 is the broadcast address. All connected devices will react...

Ehsani

Thanks a lot pylon. You are totally correct. The problem is solved by using extended addressing.

Go Up