I2C on NUCLEO-STM32F091RC board

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
fpie
Posts: 6
Joined: Tue Jan 22, 2019 7:48 am
Contact:

I2C on NUCLEO-STM32F091RC board

Post by fpie » Sun Mar 17, 2019 1:27 pm

Hi everybody,
I did some test on the NUCLEO-F091RC board with the genuine board files. I can't import hardware I2C on this platform.

Code: Select all

MicroPython v1.10-dirty on 2019-03-17; NUCLEO-F091RC with STM32F091RCT6
Type "help()" for more information.
>>> from pyb import I2C
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name I2C
>>> from machine import I2C
>>> 

On the other hand, the software I2C is loading correctly.
Is anybody that own the NUCLEO-F091RC evaluation kit have experiment this behaviour ?

Thanks in advance

fpie
Posts: 6
Joined: Tue Jan 22, 2019 7:48 am
Contact:

Re: I2C on NUCLEO-STM32F091RC board

Post by fpie » Tue Mar 19, 2019 6:40 pm

Well, i progress a bit.
According to line 528 of /ports/stm32/main.c, we need to set MICROPY_PY_PYB_LEGACY to enable hardware I2C

Code: Select all

    #if MICROPY_PY_PYB_LEGACY && MICROPY_HW_ENABLE_HW_I2C
    i2c_init0();
    #endif
When done in the /boards/NUCLEO_F091RC/mpconfigboard.h file at line 8 :

Code: Select all

#define MICROPY_PY_PYB_LEGACY       (1)
Compilation fail with many errors concerning pyb_i2c.c (here the 3 first)

Code: Select all

pyb_i2c.c: In function 'i2c_set_baudrate':
pyb_i2c.c:220:9: error: 'I2C_InitTypeDef {aka struct <anonymous>}' has no member named 'ClockSpeed'
     init->ClockSpeed = baudrate;
         ^~
pyb_i2c.c:221:9: error: 'I2C_InitTypeDef {aka struct <anonymous>}' has no member named 'DutyCycle'
     init->DutyCycle = I2C_DUTYCYCLE_16_9;
         ^~
pyb_i2c.c:221:23: error: 'I2C_DUTYCYCLE_16_9' undeclared (first use in this function)
     init->DutyCycle = I2C_DUTYCYCLE_16_9;
                       ^~~~~~~~~~~~~~~~~~
So ?

User avatar
dhylands
Posts: 3241
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: I2C on NUCLEO-STM32F091RC board

Post by dhylands » Tue Mar 19, 2019 9:33 pm

Nobody has adapted the code to work with the F0 yet.

Post Reply