Problem with STM32F107 and I2C1

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

Moderators: RoccoMarco, barthess

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

Problem with STM32F107 and I2C1

Postby jsavonet » Fri Mar 15, 2019 2:30 pm

Hi all,

I'm currently facing an issue with I2C1 on an OLIMEX P107 board.

I first try the example provided and I2C1 on remapped pin PB8/PB9 is working just fine.
Configuration is like this in the board.h file:

Code: Select all

/*
 * Port B setup:
 * PB8  - Alternate O.D.    (I2C1 SCL, remapped).
 * PB9  - Alternate O.D.    (I2C1 SDA, remapped).
 */
#define VAL_GPIOBCRL            0x88844480      /*  PB7...PB0 */
#define VAL_GPIOBCRH            0x38BBB8FF      /* PB15...PB8 */
#define VAL_GPIOBODR            0xFFFFFFFF


Now moving the issue I'm facing. I would like to use I2C1 on pin PB6/PB7 (alternate default) since my own design is using those pins.
So I change the board.h file to this:

Code: Select all

/*
 * Port B setup:
 * PB6  - Alternate O.D.    (I2C1 SCL).
 * PB7  - Alternate O.D.    (I2C1 SDA).
 */
#define VAL_GPIOBCRL            0xEE844480      /*  PB7...PB0 */
#define VAL_GPIOBCRH            0x38BBB888      /* PB15...PB8 */
#define VAL_GPIOBODR            0xFFFFFFFF


Code is running on the board but can get any clock signal on the scope.
If someone as an hint It would be great,

Thank in advance,

Jeremy

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: Problem with STM32F107 and I2C1

Postby Giovanni » Fri Mar 15, 2019 2:33 pm

Hi,

1) Make sure to remove the alternate from the previous pins.
2) Have you activated the remap?

Giovanni

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

Re: Problem with STM32F107 and I2C1

Postby jsavonet » Fri Mar 15, 2019 2:42 pm

Hi Giovanni,

Thank you for the quick reply.

1) How to remove the alternate from the previous pin.
Is setting PB8/PB9 as input in the board.h file is ok

Code: Select all

/*
 * Port B setup:
 * PB6  - Alternate O.D.    (I2C1 SCL).
 * PB7  - Alternate O.D.    (I2C1 SDA).
 */
#define VAL_GPIOBCRL            0xEE844480      /*  PB7...PB0 */
#define VAL_GPIOBCRH            0x38BBB8[b]88[/b]      /* PB15...PB8 */


2) How I can activate/deactivate the remap feature ?

Thank you,

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

Re: Problem with STM32F107 and I2C1

Postby jsavonet » Fri Mar 15, 2019 3:18 pm

I also removed in board.c the remap feature on I2C1 ( AFIO_MAPR_I2C1_REMAP ) but still no clock signal on the scope.

Code: Select all

AFIO->MAPR |= AFIO_MAPR_USART3_REMAP_FULLREMAP |
               AFIO_MAPR_SPI3_REMAP;

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

Re: Problem with STM32F107 and I2C1 [SOLVED]

Postby jsavonet » Fri Mar 15, 2019 3:30 pm

Problem solved.
The configuration need to be:

Code: Select all

#define VAL_GPIOBCRL            0xBB844480      /*  PB7...PB0 */


Alternate push-pull output for PB6/PB7 and deactivate remap in board.c

Thanks again for the support Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 34 guests