I2C v.1.0 discrepancy RM Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
alexblack
Posts: 276
Joined: Mon Sep 24, 2012 3:52 pm
Location: Donetsk
Been thanked: 32 times
Contact:

I2C v.1.0 discrepancy RM

Postby alexblack » Tue Jun 14, 2022 12:52 pm

Hi.
In current stable branch (21.11.2) there is I2C v.1 driver and it has discrepancy with Reference Manual:

Code: Select all

"ChibiOS\os\hal\ports\STM32\LLD\I2Cv1\hal_i2c_lld.c"
...
252 static void i2c_lld_serve_event_interrupt(I2CDriver *i2cp) {
253   I2C_TypeDef *dp = i2cp->i2c;
254   uint32_t regSR2 = dp->SR2;
255   uint32_t event = dp->SR1;
...

But the Reference Manual for STM32F407 (for example) says:

Code: Select all

"Page 858 <27.6.6> DM00031020_RM0090_STM32F4xx.pdf
Bit 1 ADDR: Address sent (master mode)/matched (slave mode)
This bit is cleared by software reading SR1 register followed reading SR2, or by hardware
when PE=0.

Thus, you must first read status register 1, then 2:

Code: Select all

252 static void i2c_lld_serve_event_interrupt(I2CDriver *i2cp) {
253   I2C_TypeDef *dp = i2cp->i2c;
254   uint32_t event = dp->SR1;
255   uint32_t regSR2 = dp->SR2;
...

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: I2C v.1.0 discrepancy RM

Postby Giovanni » Tue Jun 14, 2022 1:08 pm

Hi,

Moving in bug reports.

Giovanni

User avatar
Edoardo1982
Posts: 7
Joined: Thu Aug 03, 2017 8:39 am
Been thanked: 4 times

Re: I2C v.1.0 discrepancy RM

Postby Edoardo1982 » Mon Sep 19, 2022 5:17 pm

alexblack wrote:Hi.
In current stable branch (21.11.2) there is I2C v.1 driver and it has discrepancy with Reference Manual:

Code: Select all

"ChibiOS\os\hal\ports\STM32\LLD\I2Cv1\hal_i2c_lld.c"
...
252 static void i2c_lld_serve_event_interrupt(I2CDriver *i2cp) {
253   I2C_TypeDef *dp = i2cp->i2c;
254   uint32_t regSR2 = dp->SR2;
255   uint32_t event = dp->SR1;
...

But the Reference Manual for STM32F407 (for example) says:

Code: Select all

"Page 858 <27.6.6> DM00031020_RM0090_STM32F4xx.pdf
Bit 1 ADDR: Address sent (master mode)/matched (slave mode)
This bit is cleared by software reading SR1 register followed reading SR2, or by hardware
when PE=0.

Thus, you must first read status register 1, then 2:

Code: Select all

252 static void i2c_lld_serve_event_interrupt(I2CDriver *i2cp) {
253   I2C_TypeDef *dp = i2cp->i2c;
254   uint32_t event = dp->SR1;
255   uint32_t regSR2 = dp->SR2;
...

SR1 is cleared reading SR2 at the end of event handler

Code: Select all

  /* Clear ADDR flag. */
  if (event & (I2C_SR1_ADDR | I2C_SR1_ADD10))
    (void)dp->SR2;

There is no discrepancy with RM.
Edoardo

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: I2C v.1.0 discrepancy RM  Topic is solved

Postby Giovanni » Wed Sep 21, 2022 5:28 pm

Hi,

Is this agreed? if so I will close the ticket.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 15 guests