I am attempting to implement I2C interface on the STM32F7-Discovery Board using the a VEML 6070 UV light sensor (https://www.vishay.com/docs/84277/veml6070.pdf).
The 7-bit slave address for the device is 0x38. The addresses for data access are 0x71(LSB) and 0x73(MSB)
I am not able to write or read any data from the master. When I check the HAL_Status it returns HAL_Timeout.
Some of my code is shown below:
EDIT:
void VEML6070_Init(void){
char data[1];
HAL_I2C_Master_Receive(&hi2c1, 0x18<<1, data, 1, 150);
data[0] = 0x06;
HAL_I2C_Master_Transmit(&hi2c1, 0x38<<1, data, 1, 150);
}
int main(void) {
unsigned int rawUV;
char lcd_buf[5]
uint8_t address[1];
uint8_t MSBdata[1];
uint8_t LSBdata[1];
SystemClock_Config();
MX_I2C1_Init();
MX_GPIO_Init();
VEML6070_Init();
address[0] = 0x02;
HAL_I2C_Mem_Write(&hi2c1, 0x38<<1, 0x70, I2C_MEMADD_SIZE_8BIT, address, 1, 150)
HAL_I2C_Mem_Read(&hi2c1, 0x38<<1, 0x73, I2C_MEMADD_SIZE_8BIT, MSBdata, 1, 150)
HAL_I2C_Mem_Read(&hi2c1, 0x38<<1, 0x71, I2C_MEMADD_SIZE_8BIT, LSBdata, 1, 150)
rawUV = MSBdata[0]<<8 | LSBdata[0];
sprintf(lcd_buf, "%d ", rawUV);
//GLCD_DrawString (0, 7*24, lcd_buf);
}
Does anybody have experience of implementing I2C with the STM32F7 boards, and if so are you able to shed any light on why I may be getting 'HAL_TIMEOUT'? Is it a case of me using the wrong register addresses, or is it something more complex?
Thanks.
Edit:
I have now altered the code to use the correct protocol, but I am still finding a 'HAL_TIMEOUT'.
HAL_I2C_Master_Transmit(&hi2c1, 0x38<<1, address, 1, 150);
HAL_I2C_Master_Receive(&hi2c1, 0x39<<1, MSBdata, 1, 150);
HAL_I2C_Master_Receive(&hi2c1, 0x38<<1, LSBdata, 1, 150);
Any other suggestions?