Page 1 of 1

Problem with STM32F107 and I2C1

Posted: Fri Mar 15, 2019 2:30 pm
by jsavonet
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

Re: Problem with STM32F107 and I2C1

Posted: Fri Mar 15, 2019 2:33 pm
by Giovanni
Hi,

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

Giovanni

Re: Problem with STM32F107 and I2C1

Posted: Fri Mar 15, 2019 2:42 pm
by jsavonet
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,

Re: Problem with STM32F107 and I2C1

Posted: Fri Mar 15, 2019 3:18 pm
by jsavonet
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;

Re: Problem with STM32F107 and I2C1 [SOLVED]

Posted: Fri Mar 15, 2019 3:30 pm
by jsavonet
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