cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble initializing the I2C interface

emmanuelkatto
Associate

Hi everyone, My name is Emmanuel Katto. I am having trouble initializing the I2C interface on the STM32F4 series. Could someone provide a simple example or point me to resources that detail the setup process?

 

Looking forward to your responses.

Thanks in advance!

Best,

Emmanuel Katto

3 REPLIES 3

Welcome to the forum.

You posted this under STM8 - I've moved it to STM32 for you.

The best way to get started would be with an STM32F4 Nucleo board

https://www.st.com/en/evaluation-tools/stm32-nucleo-boards.html 

https://www.st.com/en/evaluation-tools/stm32-nucleo-boards/products.html?querycriteria=productId=LN1847$$1574=Nucleo-64&aggOrder=0%7C1%7C2%7C3%7C4%7C5%7C6%7C7%7C8%7C9%7C10%7C11%7C12%7C13%7C14%7C15%7C16%7C17%7C18%7C19%7C20%7C21 

If you're using STM32CubeIDE, start a project for one of the Nucleo boards;  there are examples which illustrate most of the STM32's features - including I2C.

https://www.st.com/en/development-tools/stm32cubeide.html

https://www.youtube.com/playlist?list=PLnMKNibPkDnGtuIl5v0CvC81Am7SKpj02

 

The HAL documentation is here:

https://www.st.com/resource/en/user_manual/um1725-description-of-stm32f4-hal-and-lowlayer-drivers-stmicroelectronics.pdf

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Good video here on getting started with an STM32 Nucleo board:

https://www.youtube.com/watch?v=hyZS2p1tW-g

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
TDK
Guru

STM32CubeMX will provide the initialization code for you.

You can see an example usage of I2C here:

STM32CubeF4/Projects/STM32446E-Nucleo/Examples/I2C/I2C_TwoBoards_ComPolling/Src/main.c at e21c319e17a7f5aef332be677eaff2a0e7c316df · STMicroelectronics/STM32CubeF4 (github.com)

Note that I2C requires external pullups of around 2.2kOhm on the SDA and SCL lines.

If you feel a post has answered your question, please click "Accept as Solution".