Using I2C for any device on STM32 with HAL | VIDEO 26

preview_player
Показать описание
Time stamps:
Theory of i2c: 01:18
Hardware initialization: 14:12
Important I2C HAL functions: 15:44

In this video I describe how I2C interface works in general and in the case of STM32 using HAL. I provide you with two examples using different i2c devices, one old TI adc called ADS7828 and a newer MAXIM temperature sensor MAX30205 to show differences in datasheets and i2c implementations.

Analog devices page on i2c:

Code and picture of configuration for this video can be found in the following link:
Рекомендации по теме
Комментарии
Автор

Yep, probably the best tutorial on I2C on STM32 devices, and it removes some of the mystery of HAL functions that scare the bejesus out of most of us. Thanks, Matej.

kenwallace
Автор

it's not easy to find a good tutorial with this setup. thanks!

lerymisandari
Автор

Wow, the best I2C tutorial I've ever seen. Thx Matej. And also you have good pronunciation.

dmytrokozubenko
Автор

Amazing! Your explanations are great, you touched on very important points, worked with the worksheet and your voice is relaxing haha
Tahnk you!

BenskiGameWorks
Автор

Hi @Matej: (min 17:38). HAL_Master_Transmit and HAL_Master_Receive automatically put bit Read/Write so in theory is not necessary to put (0x48 << 1) | 0x01. Only (0x48 << 1).

aitorsierra
Автор

I believe when using HAL functions MEM read and write (or maybe transmit/receive) there is no need to OR the LSB (the read/write bit). The function does this for you. I recently created a program using 3 I2C devices using Hal library and all of them worked without ORing the LSB (=1). Otherwise great video.

tombailey
Автор

Excellent demonstration of how to use I2C with HAL. Following your general procedure I was able to setup AS5048B 14-bit rotary position sensor from AMS. Which was much faster than doing it manually through register manipulation.
Have you considered going over CMSIS for communication protocols, or using register manipulation? Your through style of explanation is appreciated, Thanks.
Keep up the good work.

jesset-p
Автор

Hi how much is the time between interrupt(falling or rising edge) and function in normal case and how we can decrease this time ?
(Doing the function immediately after interrupt without any delay)

Musicroombar
Автор

dont say for any device
i have been working for months on nucleo f446re to read fron i2c eeprom using address 0x78
with HAL or LL
tried arduino ide softwrie on all pins
but 0x78 reserved for 10 bit addressing mode and RTC bkp register 10
can you help me

adelgeddo
Автор

Excellent content, could you please make a video about how to communicate with mcp9600 thermo sensor as it's not straight forward

kratos
Автор

Can someone explain me why config is 0x44? I cannot find the related information.

anilkoluacik
Автор

Thank you a lot for this video, it's helpful to learn how to modify the I2C with CubeMX IDE.

ABABA
Автор

Thank u for the best I2C video!
I tried to do it like you in the video and I use the AT30TS750A temperature sensor. I set the A0, A1 and A2 to ground. So I get the 48 hex address and I shifted it. For the Config Address I got 0x00 like on page 18 in the data sheet (default). The rest I dis the same as you in the video. (Expect the conversion of the temperature).
But if I debug the code I get at the first if-case the HAL_Error. Do you know what I did wrong?

With the oscilloscope, I also get no signal on the bus while debugging.

Thanks in advance!

Scouter
Автор

Do you know of any caveats if STM's HAL library has any I2c issues? For example, when to use hal_i2c_master_transmit () vs HAL_I2C_Mem_Read/Write()?


I understand the former sends the register address first (start, address, stop), while the latter, send start bit, slave I2C address, slave internal mem address, repeat start, data, stop.. i.e no stop in the middle.

I'm using stm32h7 and seeing issues with a temp sensor.. not sure if I should try a third-party/opensource driver (ex. adastra-soft).

bennguyen
Автор

Greetings! This is indeed one of the most helpful videos on the web regarding I2C, thank you Matej!

However, is it possible to generate a repeated start with the HAL functions? It appears that a stop condition is generated after each function, which is inconvenient given that a lot of IC require a repeated start before sending the requested bytes back to the master. (It is visible in your datasheet as well)
After hooking up a logic analyser to the scl and sda I saw that no matter which function was used, a stop condition was always generated.

Your help would be of great use since I am doing my internship project and have been stuck on this problem for a while...

Joro
Автор

Great video. What about using interrupt to read I2C?

vscm
Автор

Hello, can you explain in other video this pointers, the use of them in functions

alexandrev.
Автор

Do you have any setup source for cubeide in Fedora

alihancoban
Автор

Creative video, thanks for sharing it :)

RixtronixLAB
Автор

8:59 "the data pins...", please fix to "the address pins"

fpgaguy