I2C.mod for STM32F207 issue?

General discussions about working with the Astrobe IDE and programming ARM Cortex-M3, M4 and M7 microcontrollers.
Post Reply
gray
Posts: 62
Joined: Tue Feb 12, 2019 2:59 am

I2C.mod for STM32F207 issue?

Post by gray » 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.

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;
Caveat: my only test case is the "seesaw" chip on the Adafruit 1.8" display.

cfbsoftware
Site Admin
Posts: 423
Joined: Fri Dec 31, 2010 12:30 pm
Contact:

Re: I2C.mod for STM32F207 issue?

Post by cfbsoftware » Fri Jan 10, 2020 3:50 am

Thank you!

Post Reply