B4R Question Detect error of an I2C slave

Gerardo Tenreiro

Active Member
Licensed User
Hello again and first of all thank you very much for your help.
Having said this, we enter the mess
I have 7 I2C devices model TCA9554, six of them work correctly and one of them is broken or poorly soldered, that is not the problem.
The scheme we are talking about is this:

Specifically, address 33 in decimal.
When executing this piece of code at any address other than 33, the program works correctly and the parser shows this:


Note that it is "Write 32 -> 0 -> ACK -> Read ->32 ->NACK"
The translation is to tell slave 32 that we are going to read record 0, he confirms with ACK and then we ask the slave for 1 record, record 0
The code used is this:

Now if instead of slave 32 I change the address of the slave to 33 with the following code:

Dim Dire As Byte = 33



an error is generated in the ESP32 that completely blocks it and even enters a loop of continuous restarts.

The query is:
How can I read the first ACK of the frame or, failing that, solve the problem so that the program detects that this I2C slave is not working correctly and take measures before the ESP32 stops completely?

As always, thank you very much and I am open to any suggestion.
 

Smartopt

New Member
  1. Send a start sequence.
  2. Send 0xC0 ( I2C address of the CMPS03 with the R/W bit low (even address)
  3. Send 0x01 (Internal address of the bearing register)
  4. Send a start sequence again (repeated start)
  5. Send 0xC1 ( I2C address of the CMPS03 with the R/W bit high (odd address)
  6. Read data byte from CMPS03.
 
Upvote 0

Gerardo Tenreiro

Active Member
Licensed User
Hello and thank you very much for your help, but I will comment. That was the first thing I wanted to do, the first part is no problem, I send data to the slave and any register. the slave does not respond "NACK" is seen in the parser frame. Later, when I try to read it, the problem is generated since the variable is not created and when I try to read it, the ESP32 restarts.
At the moment I am solving it by checking the length of the variable, if it is less than 1 I no longer read it and I assume that the TCA is broken.
It is a way out of the problem but the good thing would be to be able to read the ACK or the NACK of the slave so that it could make the decision before trying to read it.
Keep in mind that I have many more I2C and SPI devices on this board so the ESP32 is pretty tight on time and I don't want to waste time on the operation.
Also thank you very much for the help
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…