Topics

Going mad about I2C #i2c #stm32 #nrf51822


Roman Tataurov
 

Hello!

Today almost whole day frustrating trying to make work I2C on Zephyr.
Tested on 2 different boards with nrf51822 and stm32f103 MCU-s and got no success.

Any options for both MCU-s different than bitbang I2C even return null for device_get_binding so I can't even initialize it. 
In case of bitbang I2C implementation device driver exists but does not work. Mean code executed, but I see nothing on MCU pins. 
Mapped to different GPIO variants, checked with logick analyzer on all the pins but nothing. It just does not work at all.

So can anobody explain right path to make it finally work.

So for STM32 (not a bitbang) used with:

CONFIG_GPIO=y
CONFIG_GPIO_STM32=y
CONFIG_GPIO_STM32_PORTA=y
CONFIG_GPIO_STM32_PORTB=y

CONFIG_I2C=y
CONFIG_I2C_INIT_PRIORITY=60
CONFIG_SYS_LOG_I2C_LEVEL=4
# CONFIG_I2C_0 is not set     <-------- tested with this as well
CONFIG_I2C_1=y 
# CONFIG_I2C_2 is not set
# CONFIG_I2C_3 is not set
# CONFIG_I2C_DW is not set
# CONFIG_I2C_GPIO is not set
# CONFIG_I2C_SBCON is not set
CONFIG_I2C_STM32=y
CONFIG_I2C_STM32_V1=y

For nrf51 dont remember but can try again and put config here.

Any help appreciated.



Rodrigo Peixoto <rodrigopex@...>
 

Hi Roman,

I was taking a look at the list and I've found something that may help you. Go to the link https://lists.zephyrproject.org/g/users/message/371 and check the solution. I think that maybe you can try something similar to that. Remember that the hardware used in the example is a nrf52 and yours is a nrf51, but the device names for this case are the same.

The STM32F103 I don't know the dev name. You can check that directly on the source code (board.h -> https://github.com/zephyrproject-rtos/zephyr/blob/d6e3f22fddccf4b542cb5ec780440cb629c12290/boards/arm/nucleo_f103rb/board.h). Maybe the name for the device is PORTA or PORTC it depends on the which one is the I2C port for your project.

I hope it helps.

Best regards, Rodrigo Peixoto. Ayna Tech +55 (82) 98144-8585.


Rodrigo Peixoto <rodrigopex@...>
 

Describe better your environment.

Which board (and no MCU) are you using? Based on the http://docs.zephyrproject.org/boards/arm/nucleo_f103rb/doc/nucleof103rb.html it seems that the i2c_1 that it might be the I2C_0 in Zephyr is on the PORTB. I have added the following line #define CONFIG_I2C_0_NAME "PORTB". For the https://github.com/zephyrproject-rtos/zephyr/tree/d6e3f22fddccf4b542cb5ec780440cb629c12290/samples/drivers/i2c_fujitsu_fram example. It compiles but I don't have the board here to test.

Try this and let us know.

Best regards, Rodrigo Peixoto.


Roman Tataurov
 

MCU is this https://github.com/zephyrproject-rtos/zephyr/tree/d6e3f22fddccf4b542cb5ec780440cb629c12290/arch/arm/soc/st_stm32/stm32f1
Using this board https://github.com/zephyrproject-rtos/zephyr/tree/d6e3f22fddccf4b542cb5ec780440cb629c12290/boards/arm/stm32_min_dev

Seems it completely off i2c devices so added to board dts 

&i2c1 {
        status = "ok";
};
 
&i2c2 {
        status = "ok";
};
To make it work. Together with bug fixed about DTS https://github.com/zephyrproject-rtos/zephyr/issues/7248 I have now I2C device created. So code is work now. 
But still no activities on device pins. Checked all the pins with logick analser and found nothing.

I suspect some GPIO setup required.


Yannis Damigos
 

Hi Roman,

you need to update boards pinmux.c file to add the I2C pins. You could
check olimexino_stm32 board's pinmux file for reference.

Yannis
On Mon, Apr 30, 2018 at 10:36 AM Roman Tataurov <diytronic@...> wrote:

MCU is this
https://github.com/zephyrproject-rtos/zephyr/tree/d6e3f22fddccf4b542cb5ec780440cb629c12290/arch/arm/soc/st_stm32/stm32f1
Using this board
https://github.com/zephyrproject-rtos/zephyr/tree/d6e3f22fddccf4b542cb5ec780440cb629c12290/boards/arm/stm32_min_dev

Seems it completely off i2c devices so added to board dts
&i2c1 {
status = "ok";
};
&i2c2 {
status = "ok";
};
To make it work. Together with bug fixed about DTS
https://github.com/zephyrproject-rtos/zephyr/issues/7248 I have now I2C
device created. So code is work now.
But still no activities on device pins. Checked all the pins with logick
analser and found nothing.

I suspect some GPIO setup required.