STM32L496 I2C2 configuration issue

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
jsavonet
Posts: 11
Joined: Fri Mar 01, 2019 10:00 am
Been thanked: 1 time

STM32L496 I2C2 configuration issue

Post by jsavonet »

Hi all,

I have a custom board on which I have an I2C chip connected on PB10/11 (I2C2). Unfortunatly, the board was made before I read the errata sheet in which it is mentionned that I2C2 on PB10/11 cannot be used in FastMode (Murphy Law :D )

On this same board I have other peripherals on I2C3 that are working fine.

The problem is that I cannot managed to configure my I2C2 in standard mode so that I can be compliant with the errata and I can use those sensors.

If someone can help It would be so nice,

Regards,
Jeremy S.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32L496 I2C2 configuration issue

Post by Giovanni »

Hi,

What is the problem exactly?

Giovanni
jsavonet
Posts: 11
Joined: Fri Mar 01, 2019 10:00 am
Been thanked: 1 time

Re: STM32L496 I2C2 configuration issue

Post by jsavonet »

Hi Giovanni,

I forgot to post the I2C configuration. Here is the configuration:

Code: Select all

            STM32_TIMINGR_PRESC( 8U ) | STM32_TIMINGR_SCLDEL( 4U ) |
            STM32_TIMINGR_SDADEL( 2U ) | STM32_TIMINGR_SCLH( 15U ) |
            STM32_TIMINGR_SCLL( 19U ),
            0,
            0,


The problem is that with I2C2 configured on pin PB10/PB11 my chip is not responding to a ping command while on I2C3 with exact same configuration chip is working well.

Code: Select all

            // Set pad mode for I2C2
            palSetPadMode(
                GPIOB,
                10,
                PAL_MODE_ALTERNATE( 4 ) | PAL_STM32_OTYPE_OPENDRAIN );
            palSetPadMode(
                GPIOB,
                11,
                PAL_MODE_ALTERNATE( 4 ) | PAL_STM32_OTYPE_OPENDRAIN );
jsavonet
Posts: 11
Joined: Fri Mar 01, 2019 10:00 am
Been thanked: 1 time

Re: STM32L496 I2C2 configuration issue

Post by jsavonet »

Hi again,

I found a configuration in ChibiOS testhal folder that fix my issue:

Code: Select all

  STM32_TIMINGR_PRESC(15U) |
  STM32_TIMINGR_SCLDEL(4U) | STM32_TIMINGR_SDADEL(2U) |
  STM32_TIMINGR_SCLH(15U)  | STM32_TIMINGR_SCLL(21U),
  0,
  0
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32L496 I2C2 configuration issue

Post by Giovanni »

Ah good :) Do you have appropriate pullups externally?

Also note that in ChibiOS there is a little known I2C fallback implementation done in SW, when everything else fails you can try that.

Giovanni
jsavonet
Posts: 11
Joined: Fri Mar 01, 2019 10:00 am
Been thanked: 1 time

Re: STM32L496 I2C2 configuration issue

Post by jsavonet »

Thank you Giovanni for the help,

Yes my pullups are good so far.
I'll give a look at the fallback feature,

++
Post Reply