An absolute beginner needs help programming peripheral devices with the STM32Cube
- February 3, 2021
- 4 replies
- 1165 views
Hello ,
I'm using the latest STM32Cube with NUCLEO144-H743ZI2 board.
I am a complete beginner with using the STM32 and STM32Cube. I came from the ESP32 world, where everything was relatively easy. Through numerous attempts, I can now handle the STM32Cube (especially the STM32CubeMX), even if some terms that appear there are still unknown to me.
At the beginning I set the goal to get the TSL2591 sensor running. Communication with this component takes place via the I2C bus (I2C1).
In the STM32CubeMX I have specified that the pins PB8 and PB9 should be used for SCL and SDA respectively. In the generated code I cannot see this definition anywhere! That is my first problem.
When I debug the code, calling the procedure "tsl2591_initialize()" leads to calling the function "I2C_IsAcknowledgeFailed()" in the file "stm32h7xx_hal_i2c.c", lines 6377ff. The first query of the flag "I2C_FLAG_AF" says that this flag is set. The execution of the following loop "while (__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_STOPF) == RESET)" is exited, but the code afterwards leads to the return with error. I can't recognize the reason for this. Probably something is missing in my code.
What am I doing wrong?
Can anybody help me to get this code running?
I've put the entire project in the attachment.
Thanks in Advance,
Michael
