Open hgrodriguez opened 1 year ago
I have a fix, but I'm afraid it might break other I2C devices. Please test out the https://github.com/JeremyGrosser/rp2040_hal/tree/issue_49 branch and let me know if it solves your problem.
Thanks I will look at it as early as I can. Currently my work bench has another project so maybe next weekend
i checked and the behaviour did not improve, same separation of the address still there. When I remember correctly, pico_bsp 1.6.0 worked fine with 16 bit addresses, not sure what you changed in the i2c code. I will try to spend more time, but at the moment I have a different project going.
I had some time to debug in the libraries. I am not sure, if this helps, what I write below. My view is, that if I call a procedure multiple times with the very same parameters, then the behaviour should be the same. I found the following using the code above.
The first time I call Port.Mem_Write on line 49, I found out, that in the procedure RP.I2C.Write the flags for:
P.IC_DATA_CMD :=
(RESTART => (if This.Repeated_Start and P.IC_DATA_CMD.FIRST_DATA_BYTE = ACTIVE then ENABLE else DISABLE),
STOP => (if not This.Repeated_Start and This.TX_Remaining = 1 then ENABLE else DISABLE),
CMD => WRITE,
DAT => Data,
others => <>);
result in:
P.IC_DATA_CMD :=
(RESTART => DISABLE,
STOP => DISABLE,
CMD => WRITE,
DAT => Data,
others => <>);
The second time I call Port.Mem_Write on line 89, I found out, that in the procedure RP.I2C.Write the flags for:
P.IC_DATA_CMD :=
(RESTART => (if This.Repeated_Start and P.IC_DATA_CMD.FIRST_DATA_BYTE = ACTIVE then ENABLE else DISABLE),
STOP => (if not This.Repeated_Start and This.TX_Remaining = 1 then ENABLE else DISABLE),
CMD => WRITE,
DAT => Data,
others => <>);
result in:
P.IC_DATA_CMD :=
(RESTART => ENABLE,
STOP => DISABLE,
CMD => WRITE,
DAT => Data,
others => <>);
As written above, not sure if this helps, but even having the very same parameters in both calls, I would not expect, that those flags are different. Maybe this is a hint for you.
I would like to offer to send you EEPROMS like the ones I use: https://www.mouser.com/ProductDetail/Microchip-Technology/24FC64F-I-P?qs=WqWCsLCZBkoe3htI4nCQOg%3D%3D and ship it to your private address if this helps to debug. Let me know.
I believe I've fixed the behavior of RP.I2C_Master
with release 2.4.0. Sorry it took so long.
I2C: 16bit EEPROM adresses are split on the SECOND read
Hi Jeremy, I spent some time investigating my code and could not find the problem. Then I came back to your code and adjusted it a little bit to enable me to debug it better. I do appreciate, that you do not have time to resolve this soon, I just wanted to make sure that I used your code (not mine) to reproduce it. Let me know, if I did something wrong.
I have this in my alire.toml: [[depends-on]] pico_bsp = "^2.0.0"
See code below:
I used GDB to step through the program, but the same behaviour is true if run as normal without debugger attached.
Those are the results: Write Data=1 -> OK
Read Data=1 -> OK
Write Data=2 -> OK
Read Data=2 -> NOK