2 years, 2 months ago.

i2c or PA_6, PA_5 pins configuration bug in NUCLEO_F031K6

Hi, guys!

The problem exists in NUCLEO_F031K6. I am using mbed-dev. If you try to work with i2c on PB_7, PB_6 pin everything OK. But if you try to declare DigitalOut on PA_6 (or PA_5) it will broke i2c (return from i2c.write & with error). I do not know how pins PA_6 and PB_7, PB_6 is connected in mbed configuration. Please help to fix or give some advice where to search the problem roots.

bug reproduce

#include "mbed.h"

I2C i2c(PB_7, PB_6);

//if you declare DigitalOut on PA_6 pin read/write i2c operation will fail.

DigitalOut tryToBrokeI2c(PA_6);

 int main() { 
  //!!! use your code to work with your i2c device
  int address = 0x62;
  char data[2];
  data[0] = 0;
   data[1] = 1; 
   if(i2c.write(address, data, 2))
      printf("i2c write fail");
   if(, data, 2))
      printf("i2c read fail");
Comment on this question

1 Answer

2 years, 2 months ago.

Of course check the manual and schematic

See pages 20 and 21. It appears PA5 and PA6 cannot be used as a digital output unless you remove bridge SB16 and SB18. Page 22 suggests you might have more luck with say, PA_4. There are no special notes for that pin.

I really appreciated your help. Thank you very much!

posted by pressurecontrol pressurecontrol 08 Jun 2017