Question
Clock / Timing problem in I2C
I am trying to run a loopback test with 2 i2c's on the same board. The onboard leds need to light up on successful transmission and reception, the problem is the leds light up when in debug mode, going line by line, but not in stand
#define I2C1_ADD (0x15<<1)
#define I2C2_ADD (0x42<<1)
uint8_t I2C1_tx='1';
uint8_t I2C2_tx='2';
uint8_t I2C1_rx,I2C2_rx;
HAL_I2C_Slave_Receive_IT(&hi2c2,&I2C2_rx,sizeof(I2C1_tx));
HAL_Delay(100);
HAL_I2C_Master_Transmit(&hi2c1,I2C2_ADD,&I2C1_tx,sizeof(I2C1_tx),1000);
HAL_I2C_Slave_Receive_IT(&hi2c1,&I2C1_rx,sizeof(I2C2_tx));
HAL_Delay(100);
HAL_I2C_Master_Transmit(&hi2c2,I2C1_ADD,&I2C2_tx,sizeof(I2C2_tx),1000);
while(1)
{
if(I2C2_rx==I2C1_tx)
{
HAL_GPIO_WritePin(GPIOG,GPIO_PIN_13,SET);
HAL_Delay(100);
}
if(I2C1_rx==I2C2_tx)
{
HAL_GPIO_WritePin(GPIOG,GPIO_PIN_14,SET);
HAL_Delay(500);
}
}alone. Can someone plz suggest what might be wrong.
