cancel
Showing results for 
Search instead for 
Did you mean: 

How to send data from MCU over I2C?

Berger1
Associate

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.

2 REPLIES 2

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
Up vote any posts that you find helpful, it shows what's working..
Issac Cheung
Associate
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