I2C.mod for STM32F207 issue?
Posted: Wed Jan 08, 2020 1:31 pm
I think the procedure 'Read' in I2C.mod for the STM32F207 is not correct for read data > 2 bytes.
Consider the "big" IF-statement, for the count > 2 case:
1) ACK should get enabled to implement the protocol as per the timing diagram in the reference manual.
2) the index 'i' into data is ahead by one after the WHILE loop -- it got already incremented in the loop when it exits.
Caveat: my only test case is the "seesaw" chip on the Adafruit 1.8" display.
Consider the "big" IF-statement, for the count > 2 case:
1) ACK should get enabled to implement the protocol as per the timing diagram in the reference manual.
2) the index 'i' into data is ahead by one after the WHILE loop -- it got already incremented in the loop when it exits.
Code: Select all
IF count = 1 THEN
(* ... *)
ELSIF count = 2 THEN
(* ... *)
ELSE
SetBit(CR1, ACK); (* 1) enable ACK *)
i := 0;
WHILE count > 3 DO
(* ... *)
INC(i);
DEC(count)
END;
(* ... *)
SYSTEM.GET(DR, data[i]); (* 2) i was INC-ed in the WHILE loop *)
(* ... *)
SYSTEM.GET(DR, data[i + 1]); (* 2) *)
(* ... *)
SYSTEM.GET(DR, data[i + 2]) (* 2) *)
END;