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:
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.
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:
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600
#End Region
'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src
Sub Process_Globals
Dim T_Ciclo As Timer
Dim Bus As WireMaster
Dim Serial1 As Serial
Dim Dire As Byte = 32
End Sub
Private Sub AppStart
Dim D(2) As Byte
Serial1.Initialize(9600)
Log("Arranque...")
T_Ciclo.Initialize("T_Ciclo_Tick",100)
T_Ciclo.Enabled = True
' Inicializa el Bus
Bus.Initialize
' Velocidad del Bus I"C 400khz
RunNative("SetWireClock", 400000)
D(0) = 3
D(1) = 255
'
Bus.WriteTo(Dire,D)
End Sub
Private Sub T_Ciclo_Tick
Dim Regi(1) As Byte
Regi(0) = 0
'
Bus.WriteTo(Dire,Regi)
Dim V0() As Byte = Bus.RequestFrom(Dire, 1)
'
Log("Long = ",V0.Length," ... ",V0(0))
End Sub
' Ajusta la Velocidad del Bus I2C
#if C
void SetWireClock(B4R::Object* o) {
Wire.setClock (o->toULong());
}
#end if
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.