Skip to main content
Berger1
Visitor II
May 31, 2020
Question

How to send data from MCU over I2C?

  • May 31, 2020
  • 2 replies
  • 1290 views

I have array unsigned char data[1024] in RAM , and I need to send them to the display on I2C, this is not problem HAL_I2C_Master_Transmit( data ) works fine.

Now I need to send the same data, but so that the sequence starts with a control byte.

is IT possible to use two function calls

HAL_I2C_Master_Transmit(Control_byte):

HAL_I2C_Master_Transmit(data);

Respectively, the result on i2C will be the same as when I send

dataWithCB=Control_byte+data;

HAL_I2C_Master_Transmit(dataWithCB):

or how else to send the data so that the result is the same

Thanks for info.

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
May 31, 2020

What specifically does the display data sheet say it needs?

Some connect to the I2C slave, send an address, and then a byte stream. The internal address may be 1 or 2 bytes wide.

One could presumably use two calls, copy to a temp buffer, or daisy chain from a scatter-gather list using the interrupt versions.

See HAL_I2C_Mem_Write() forms

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Issac Cheung
Associate
June 4, 2020
HAL_I2C_Master_Seq_Transmit_IT(&hi2c, I2C_ADDR, &control_byte, 1, I2C_FIRST_FRAME);
 
/* wait transmit complete */
while (HAL_I2C_GetState(&hi2c) != HAL_I2C_STATE_READY);
 
HAL_I2C_Master_Seq_Transmit_IT(&hi2c, I2C_ADDR, data, sizeof(data), I2C_LAST_FRAME);
 
/* wait transmit complete */
while (HAL_I2C_GetState(&hi2c) != HAL_I2C_STATE_READY);

don't know if this works for you