Skip to main content
Associate III
April 22, 2024
Solved

Cude max

  • April 22, 2024
  • 6 replies
  • 4111 views

 

I hope this message finds you well. I am reaching out regarding an urgent matter with my STM32 CubeMX v6.1 project. I have encountered an issue with the I2C functionality that I cannot seem to resolve despite trying various approaches.

The specific problem arises with the following function:

SMazu3_0-1713767509891.pngSMazu3_1-1713767529673.pngSMazu3_2-1713767543607.pngSMazu3_3-1713767569402.png

SMazu3_4-1713767620074.png

 

I have attempted to implement this function across different STM microcontroller units, including STM32WB10, STM32F750, and STM32F103, but unfortunately, the issue persists consistently across all of them. It's worth noting that I have verified the hardware compatibility by successfully testing it with Arduino and ESP32 platforms.

Given that I have a project deadline looming, I urgently require your assistance in resolving this matter. Any guidance or insights you can provide would be greatly appreciated.

Thank you very much for your prompt attention to this matter. I look forward to your response.

This topic has been closed for replies.
Best answer by Tesla DeLorean

What's the first bit map of.code fragment about?

Probably issue not where you're looking.

State slave part and connectivity. 

Don't use internal pull up on AF OD. Use an external pull up likely in 1K5 to 2K7 range.

6 replies

SMazu.3Author
Associate III
April 22, 2024

"if (I2C_WaitOnTXISFlagUntilTimeout(hi2c, Timeout, Tickstart) != HAL_OK)

{

return HAL_ERROR;

}"

 

this function is come true.

 

 

AScha.3
Super User
April 22, 2024

@SMazu.3  , what i dont understand :

you call (blocking) HAL_I2C_Master_Transmit() , that will return success or error

and then (i assume - you dont show your program) I2C_WaitOnTXISFlagUntilTimeout() to check --- what ?

 

TXIS flag ?

AScha3_0-1713770522031.png

-> transmit interrupt status : but you dont use interrupt call at all.

I would say: just leave it away or use interrupt I2C calls.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
April 22, 2024

What's the first bit map of.code fragment about?

Probably issue not where you're looking.

State slave part and connectivity. 

Don't use internal pull up on AF OD. Use an external pull up likely in 1K5 to 2K7 range.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
SMazu.3Author
Associate III
April 22, 2024

already using 4k7 with 3v3

SMazu3_0-1713772045973.png

 

Pavel A.
Super User
April 22, 2024

MC3479 It's MEMSIC accelerometer

I2C: supports 400 KHz and fast mode +. Has two interrupt pins with programmable mode/polarity. 

The 7-bit address can be 0x4C or 0x6C (see the PDF pg, 35).

 

SMazu.3Author
Associate III
April 22, 2024

hw is working i test that with Arduino and esp32 and esp8266, 

 

stm code is no working. WaitOnTXISFlagUntilTimeout come Hal_Error very time.

 

with Master mode Slave mode and and all i2c code by cube ide or cube max have this problem 

with stm32wb10 stm32f103. and stm32f750

Pavel A.
Super User
April 22, 2024

Consistency is good, it hints that you're doing something generally wrong for the ST library. Check that you pass the I2C address in correct format. 

 

Tesla DeLorean
Guru
April 22, 2024

Get a scope or analyzer on the signals and understand what's happening there.

Show ALL initialization code for I2C and the pins. Hard to debug with level of detail presented. You'll need to dig until you understand the problem.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
SMazu.3Author
Associate III
April 22, 2024

Create a simple i2c code in stm32 cube mx with default settings.  

 

Run a simple hal_i2c_tresmit code. And check this code is working on cube ide. 

 

In my case it return me hal_error. 

Pavel A.
Super User
April 22, 2024

Ok. Then can  you please change a bit your simple project and instead of transmit call HAL_I2C_IsDeviceReady. Will it return error too? Will it succeed if you change address to 0x6C? 

 

Pavel A.
Super User
April 23, 2024

Then the electric connection of the I2C device is not good. It does not respond to either of its two possible addresses.

To be sure, do another try with read access: HAL_I2C_IsDeviceReady with addresses (0x4C <<1 | 1) and (0x6C <<1 | 1)