cancel
Showing results for 
Search instead for 
Did you mean: 

I2c Xfer Options Explanations

tomm5771
Associate III

I am looking at the definition ST gives for each of the Xfer options, but so far none of them really are making sense to me. First off, what is Sequential usage vs non-sequential usage and how does this apply for the following:

I2C_FIRST_AND_LAST_FRAME

I2C_FIRST_FRAME

I2C_FIRST_AND_NEXT_FRAME

I2C_NEXT_FRAME

I2C_LAST_FRAME

I2C_LAST_FRAME_NO_STOP

I2C_OTHER_FRAME

1 ACCEPTED SOLUTION

Accepted Solutions
Saket_Om
ST Employee

Hello @tomm5771 

 

In the context of I2C communication, the HAL library defines several transfer options to manage the sequence of frames during an I2C transaction. These options are used to indicate how the I2C controller should handle each part of the communication process, particularly when dealing with multi-frame communications.

Let's explain the concepts of sequential and non-sequential usage:

  • Sequential usage refers to a situation where multiple frames of data are sent or received in a sequence without interruption. This is common in scenarios where a large amount of data needs to be transferred that cannot fit into a single frame.
  • Non-sequential usage implies that each frame of data is sent or received independently, and there may be a stop condition or a repeated start condition between frames.

Now, let's explain each of the Xfer options:

I2C_FIRST_AND_LAST_FRAME

This option is used when the transaction consists of a single frame. It indicates that this frame is both the first and the last frame of the transaction. The I2C controller will generate a start condition at the beginning and a stop condition at the end of this frame.

I2C_FIRST_FRAME

This option is used to indicate the start of a multi-frame transaction. The I2C controller will generate a start condition and will expect more frames to follow. No stop condition is generated after this frame, allowing the transaction to continue with the next frame.

I2C_FIRST_AND_NEXT_FRAME

This option is similar to I2C_FIRST_FRAME but is specifically used when you know that there will be at least one more frame following the first frame. It prepares the I2C controller for a continued transaction without generating a stop condition.

I2C_NEXT_FRAME

This option is used for frames that are neither the first nor the last in a multi-frame transaction. It indicates that the frame is part of a sequence and that there will be subsequent frames. No start or stop conditions are generated, as the transaction is already in progress.

I2C_LAST_FRAME

This option is used for the final frame in a multi-frame transaction. It indicates that no more frames will follow, and the I2C controller will generate a stop condition after this frame to end the transaction.

I2C_LAST_FRAME_NO_STOP

This option is similar to I2C_LAST_FRAME but does not generate a stop condition at the end of the frame. This can be used when the master plans to send a repeated start condition to begin a new transaction immediately after the current one.

When implementing I2C communication, it's important to choose the correct Xfer option based on the sequence and structure of your data transfer. This ensures that the I2C controller handles the start and stop conditions appropriately and that the communication with the I2C slave device is successful.

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

View solution in original post

1 REPLY 1
Saket_Om
ST Employee

Hello @tomm5771 

 

In the context of I2C communication, the HAL library defines several transfer options to manage the sequence of frames during an I2C transaction. These options are used to indicate how the I2C controller should handle each part of the communication process, particularly when dealing with multi-frame communications.

Let's explain the concepts of sequential and non-sequential usage:

  • Sequential usage refers to a situation where multiple frames of data are sent or received in a sequence without interruption. This is common in scenarios where a large amount of data needs to be transferred that cannot fit into a single frame.
  • Non-sequential usage implies that each frame of data is sent or received independently, and there may be a stop condition or a repeated start condition between frames.

Now, let's explain each of the Xfer options:

I2C_FIRST_AND_LAST_FRAME

This option is used when the transaction consists of a single frame. It indicates that this frame is both the first and the last frame of the transaction. The I2C controller will generate a start condition at the beginning and a stop condition at the end of this frame.

I2C_FIRST_FRAME

This option is used to indicate the start of a multi-frame transaction. The I2C controller will generate a start condition and will expect more frames to follow. No stop condition is generated after this frame, allowing the transaction to continue with the next frame.

I2C_FIRST_AND_NEXT_FRAME

This option is similar to I2C_FIRST_FRAME but is specifically used when you know that there will be at least one more frame following the first frame. It prepares the I2C controller for a continued transaction without generating a stop condition.

I2C_NEXT_FRAME

This option is used for frames that are neither the first nor the last in a multi-frame transaction. It indicates that the frame is part of a sequence and that there will be subsequent frames. No start or stop conditions are generated, as the transaction is already in progress.

I2C_LAST_FRAME

This option is used for the final frame in a multi-frame transaction. It indicates that no more frames will follow, and the I2C controller will generate a stop condition after this frame to end the transaction.

I2C_LAST_FRAME_NO_STOP

This option is similar to I2C_LAST_FRAME but does not generate a stop condition at the end of the frame. This can be used when the master plans to send a repeated start condition to begin a new transaction immediately after the current one.

When implementing I2C communication, it's important to choose the correct Xfer option based on the sequence and structure of your data transfer. This ensures that the I2C controller handles the start and stop conditions appropriately and that the communication with the I2C slave device is successful.

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar