cancel
Showing results for 
Search instead for 
Did you mean: 

how on stm32f765zi read flags? i2c specific format

User.5
Associate

Hello.

Sorry for my bad English:)

I am trying to read flag on the device MLX90614. datasaheet Page 23. The format of a SMBus transaction which reads flags is: 0690X000008isnLQAQ.jpg

i.e i must send start->slave address->command and right away without send repeat start receive data. how to do it?

i writing code: 

/* Process Locked */
__HAL_LOCK(&hi2c1);
 
uint32_t nbytes = 0x1;
nbytes = nbytes << 16;
uint8_t txdata = 0xF0;
 
hi2c1.Instance->CR2 &=~ I2C_CR2_AUTOEND; // autoend disable
hi2c1.Instance->CR2 |= I2C_CR2_RELOAD;// RELOAD enable
hi2c1.Instance->CR2 |= sAddress;
hi2c1.Instance->CR2 |= nbytes;
 
hi2c1.Instance->CR2 &=~ I2C_CR2_RD_WRN; // read mode
 
hi2c1.Instance->CR2 |= I2C_CR2_START;        
hi2c1.Instance->TXDR |= txdata;
while ((hi2c1.Instance->ISR & I2C_ISR_TXE ) == 0  ){}
while ((hi2c1.Instance->ISR & I2C_ISR_TCR ) == 0  ){}
 
nbytes = 3;
nbytes = nbytes << 16;
hi2c1.Instance->CR2 |= nbytes;
 
hi2c1.Instance->CR2 |= I2C_CR2_RD_WRN;
hi2c1.Instance->CR2 |= I2C_CR2_START;
 
while ((hi2c1.Instance->ISR & I2C_ISR_RXNE ) == 0  ){}
 
/* Clear STOP Flag */
__HAL_I2C_CLEAR_FLAG(&hi2c1, I2C_FLAG_STOPF);
 
 /* Clear Configuration Register 2 */
 I2C_RESET_CR2(&hi2c1);
 
 hi2c1.State = HAL_I2C_STATE_READY;
 hi2c1.Mode  = HAL_I2C_MODE_NONE;
 
 /* Process Unlocked */
 __HAL_UNLOCK(&hi2c1);

and can transmit command, but can not receive data.

what i receive:

0690X000008it2zQAA.jpg

i2c and device working, becausei can receive and transmit data from the device(EEPROM/RAM).

I hope you got what I meant:) I will be grateful for any help.

0 REPLIES 0