2023-09-04 02:40 PM
My setup is as follows: I have a NUCLEO-H563ZI with an STM32H563ZIT6 and I am communicating through I2C with the 6D IMU, ISM330DCL. Moreover the ISM330DCL is on the STEVAL-MKI182V2.
My I2C-bus is very confusing. First I get everything set up exactly as this guy does in the following vid: https://www.youtube.com/watch?v=isOekyygpR8&list=PLEBQazB0HUyRYuzfi4clXsKUSgorErmBv&index=14.
Well I didn't use the same setup but of course I used the respective registers which have to be used in my case, instead of those in the video. Then I get everything running and I get a bunch of "0.0g" readings. So I decide to unplug a pull-up resistor to see if it's even working and to my surprise it did the "Error, TX" message came up and I was satisfied that it picked that up. I put the resistor back in and the "Error, TX" message doesn't go away. I rewire everything a thousand times it still didn't work. Until finally, I changed My WHO_AM_I address to "0xD5U" instead of "0xD5" and it worked... kinda. For some reason it worked transmitted 6 "0.0g" messages and then 16 "Error, TX" messages periodically as if, it needed some time to "get better "after giving 6 correct reading . And because I partially got it running I thought I could configure some CTRL-registers on my IMU so I wouldn't only get "0.0g" readings. So in the "USER code 2 begin" I wrote
buf [0]= 0x7D // 0111 1101
HAL_I2C_Mem_Write(&hi2c1, 0xD5U, 0x10U, 1, buf,1,50)
buf[0] = 0x00 // 0000 0000
HAL_I2C_Mem_Write(&hi2c1, 0xD5U, 0x17U, 1, buf,1,50);
And now nothing works. I have used an oscilloscope to see whether there is a wiring issue but no every pin has its respective voltage. I recently also used a Logic analyzer to see what the data transfer on the bus is. Apparently the peripheral doesn't want to acknowledge the Address I'm sending (0x6AU <<1 / D5U), so it responds with a NAK bit.
When the return I get from HAL_I2C_GetError() is HAL_I2C_ERROR_AF which matches the logic analyzer output. Hear a link to my .ioc file. I will also attach my main.c file.
https://1drv.ms/u/s!Ah-PFxeqZCB1kyYeq8DxfvHh5jga?e=k25hvm
Solved! Go to Solution.
2023-09-05 12:47 AM
I figured it out. In the ISM330DCL u have to connect a certain pin to Ground or VDD so u can have 2 device addresses on the same I2C bus. Well, I didn't have it connected to either one so that's on me. Apparently it had an undefined state between VDD and Ground. All in all I had to connect the SDO pin on the EVAL board to Ground
2023-09-05 12:47 AM
I figured it out. In the ISM330DCL u have to connect a certain pin to Ground or VDD so u can have 2 device addresses on the same I2C bus. Well, I didn't have it connected to either one so that's on me. Apparently it had an undefined state between VDD and Ground. All in all I had to connect the SDO pin on the EVAL board to Ground