cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 I2C communication

Ijaz  Ahmad
Associate II

Hi,

I am trying to establish I2C communication b/w I2C1 and I2C2 on Stm32f4-discovery. I used CubeMx to generate code for standard mode with the following addresses.

I2C1 = 0x5

I2C2 = 0x7

In the while (1) i added the following code.

resp = HAL_I2C_Master_Transmit(&hi2c1, 7<<1, &tsData, 1, 100);
 
If (resp == HAL_OK) {
    resp = HAL_I2C_Slave_Receive(&hi2c2, &rxData, 1, 500);
If (resp == HAL_OK) {
    If (rxData == 'a') {
     //toggle gpiod.15
      rxData =0;
    }
}
}
HAL_Delay(500);

Variables are:

uint8_t txData ='a';

uint8_t rxData =0;

HAL_StatusTypeDef resp;

Am I doing somethig wrong,? Any clue will be highly appreciated.

.

I appologize for any typo error as i am typing this question code on mobile.

0 REPLIES 0