Showing results for 
Search instead for 
Did you mean: 

How to use ST32MC0 for I2C communication over 2050 bytes?

Associate II

I am using STM32C031C6 for I2C verification.
I tried to communicate 2050 bytes of data using the HAL driver.
However, it did not receive the correct data.
To be precise, the data at 512,1024,1344,1346,1538,18561 and 1858 bytes were different.

The settings are as follows.
hi2c1.Instance = I2C1;
hi2c1.Init.Timing = 0x0090194B;
hi2c1.Init.OwnAddress1 = 0x10;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;

Executed with the following description.
"HAL_I2C_Master_Receive(&hi2c1, dev_addr, i2c_read, 2050, 1000);"

Please let me know how I can receive 2050 bytes of data correctly.


Accepted Solutions

Hi @Foued_KH,
Problem solved.
The cause was my mistake in writing the program.

Thanks for your support.

View solution in original post

ST Employee

Hello @kkazu , 

If you want to receive 2050 bytes of data, please flow this sequence : ( Figure 232. RM0490 )




To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi @KHALSI_Foued

Thank you for your quick response.
I used STM32CubeIDE 1.13.0 to create the template.
Checking the code generated by STM32CubeIDE 1.13.0, it seems to follow the flow you told me.
I've just started using the C language, so I may have overlooked it, so I'm attaching the generated code, so please check it.

Hi @Foued_KH,
Problem solved.
The cause was my mistake in writing the program.

Thanks for your support.

Why the hell are you attaching a HAL file, which is available for everyone anyway?