cancel
Showing results for 
Search instead for 
Did you mean: 

I2C with repeated start.

jeffl.kelley9
Associate III

I have seen the question asked many times, references made but the question never gets answered with precision.  So, once again...

I want to use HAL_I2C_Master_Seq_Transmit_IT along with receive to read an I2C device register.

1. START SLAVEADDRESSWR (N-Byte RegAddress)

2. REPEATEDSART SLAVEADDRESSRD (N-Byte returned data) STOP

Step 1 would us HAL_I2C_Master_Seq_Transmit_IT 

Step 2 would use HAL_I2C_Master_Seq_Receive_IT

What are the "Option" parameters such as I2C_FIRST_FRAME, etc. for each of these calls to avoid a STOP between the sequences and make the REPEATEDSTART occur, and of course finish up with a STOP?

And using the memory read/write calls does not work because the register memory address cannot be of arbitrary length.  Don't have a scope handy to see the protocol generated, so I won't know things are working until my device actually returns correct default register values.

 

 

 

2 REPLIES 2
TDK
Super User

Here is a working example of these functions for both the master side and the slave side:

STM32CubeU3/Projects/NUCLEO-U385RG-Q/Examples/I2C/I2C_TwoBoards_RestartComIT/Src/main.c at a88e56ca9916e3f93679559ecd9b17dc9e7a7a80 · STMicroelectronics/STM32CubeU3

The syntax is the same regardless of chip family.

HAL_I2C_Master_Seq_Transmit_IT(..., I2C_FIRST_FRAME);
...
HAL_I2C_Master_Seq_Receive_IT(..., I2C_LAST_FRAME);

 

If you feel a post has answered your question, please click "Accept as Solution".