cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 F3 I2C SCL Push-Pull Issue

GeoffF
Associate II

We're currently using STM32F373CC micros in several of our designs. Part of our standard design has an EEPROM connected via I2C. We have our own hardware layer that is tried and proven over the decades. However, it relies on the I2C port pins having pull-ups connected externally.

On some of our new designs we have designed out the pull-up on the SCL line and have set the port pin to Push-Pull mode. In theory, this should be no problem. However, what we've found is that the micro seems to be treating the port pin as open-drain regardless of the setting. For this particular design, we're using PF6 and PF7 as SCL and SDA respectively. With no pull-up connected, the SCL line is flat-lined. With internal pull-up enabled, the SCL line is pulsing, but the rise time is so long it's not working.

Nothing in the reference manual or the datasheet says anything about this issue. In the errata sheet we have (V4), there's quite a bit about the GPIO and I2C, but nothing that seems to relate to this.

For what it's worth, I'll copy and paste the relevant bit of the initialisation:

   switch( kasPinMap[eSCL].lwI2CNum )
 
   {
 
   case 1: RCC_APB1ENR.I2C1EN = TRUE; nI2CEEpsRegisters = (void*)&I2C1_CR1; break;
 
   case 2: RCC_APB1ENR.I2C2EN = TRUE; nI2CEEpsRegisters = (void*)&I2C2_CR1; break;
 
   }
 
 
   //configure the pins
 
   DIO_vConfigure( kasPinMap[eSCL].ePort,  kasPinMap[eSCL].lwBit,  DIOkeM_Alternate, DIOkeD_PushPull,  DIOkePU_None, DIOkeSP_Medium, kasPinMap[eSCL].lwAFN );
 
   DIO_vConfigure( kasPinMap[eSDA].ePort,  kasPinMap[eSDA].lwBit,  DIOkeM_Alternate, DIOkeD_OpenDrain, DIOkePU_None, DIOkeSP_Medium, kasPinMap[eSDA].lwAFN );
 
 
   //reset and enable the peripheral
 
   nI2CEE_vReset();

Although this is "non-standard" code, it definitely sets the registers correctly. In the debugger view of the registers, PF6 is definitely in push-pull mode and PF7 is open-drain, the GPIOF and I2C2 peripherals are enabled in the RCC register, and I2C works correctly if we solder an external pull-up resistor on.

Our Technical Director mentioned that to comply with the I2C standard and allow for multi-master mode, both SCL and SDA should both be open-drain. However, all we have here is the F3 and the EEPROM.

Any thoughts?

11 REPLIES 11

Experimenting on a STM32F030R8 (='F051x8) confirmed, that I2C overrides GPIOx_OTYPER there too, forcing the respective pins to be set as OD (tried PB6/PB7  I2C1 SCL/SDA AF1, PB10/PB11 I2C2 SCL/SDA AF1, PF6/PF7  I2C2 SCL/SDA AF0).

SYSCFG_CFGR1.I2CxxxxFM bits have no impact on this.

This was no surprise as the 'F0 are the little brethren of 'F3, but I somehow hoped this issue is limited to PF6/PF7.

Nasty.

JW

Thanks for that Jan,

We also use F4s in some of our designs - when we can actually find any in stock. They seem to be OK, but I'm not sure if there's been a new design without pullups since we made the change.

We have a couple of F0-based designs as well, but I know we haven't done any new versions of that for a while.

It remains to be seen whether ST bother to actually document this behaviour.

Regards,

Geoff