Skip to main content
antonius
Associate III
July 12, 2019
Question

Is my I2C sending properly ?

  • July 12, 2019
  • 2 replies
  • 550 views

Dear Members,

Is my I2C at STM32F107 sending properly ?

void lcd_send_cmd (char cmd)
	
{
 char data_u, data_l;
	uint8_t data_t[4];
	data_u = (cmd&0xf0);
	data_l = ((cmd<<4)&0xf0);
	data_t[0] = data_u|0x0C; //en=1, rs=0
	data_t[1] = data_u|0x08; //en=0, rs=0
	data_t[2] = data_l|0x0C; //en=1, rs=0
	data_t[3] = data_l|0x08; //en=0, rs=0
	HAL_I2C_Master_Transmit (&hi2c1, SLAVE_ADDRESS_LCD,(uint8_t *) data_t, 4, 100);
}
 
void lcd_init (void)
{
	lcd_send_cmd (0x02);
	lcd_send_cmd (0x28);
	lcd_send_cmd (0x0c);
	lcd_send_cmd (0x80);
	printf("LCD Init DONE!\r\n");
}

0690X000009Yfn8QAC.jpg

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
July 12, 2019

I'm not unpacking this for you.

Start with one transaction. Make sure the I2C IO Expander is responding with an ACK.

Once you know the IO Expander is responding, send bit patterns to it, and test the corresponding pins on the chip itself.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
antonius
antoniusAuthor
Associate III
July 16, 2019

it did the command already, I sent a wrong address...suppose to be 7E

0690X000009YmO0QAK.jpg

many thanks