Loading...
 
Skip to main content

System Workbench for STM32


GPIO Toggle Question

Really appreciate the help Bab! Now, that the start condition is clarified, this leads me to my next objective. I'm supposed to read from the device. The register 0x01 should have the value 0xAC as an ACK to let me know that the STA013 decoder is present. I used both:

HAL_I2C_Master_Receive(&hi2c3, reg, &data, 1, 100);
&
HAL_I2C_Mem_Read(&hi2c3, 0x86, reg, I2C_MEMADD_SIZE_8BIT, &data, 1, 10);

With reg having the value of 0x01. But, neither of those returned back the correct value. Do you know which of the two functions is the correct one? And do you see anything wrong in what I wrote?

Hey,

I haven't used the Hal library much. But i think the HAL_IC2_Master_Receive function just sends the address and then records size bytes.
This is useful for devices with a 2 step readout. In the first transmission you would tell the device which register you want to read and in the second transmission you would use this function.

And i think HAL_I2C_Mem_Read would first send the address, then the register you want to read and then record size bytes in a consecutive transmission.

Can't get more information from the usermanual and i haven't really worked with the i2c and the HAL so you better dont rely on me!

I hope someone else can help you!

Bab