Skip to main content
Associate
August 1, 2023
Solved

How to use ST32MC0 for I2C communication over 2050 bytes?

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.

This topic has been closed for replies.
kkazuBest answer
Associate
August 3, 2023

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

Thanks for your support.

4 replies

Foued_KH
ST Employee
August 1, 2023

Hello @kkazu , 

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

KHALSI_Foued_0-1690882148653.png

Foued

 

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.
kkazuAuthor
Associate
August 2, 2023

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.
kkazuAuthorBest answer
Associate
August 3, 2023

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

Thanks for your support.