NUCLEO-H743ZI with Adafruit OV5640 camera board not reading/writing on I2C bus
Hello!
I recently bought a OV5640 Adafruit breakout board from here and I was having some issues with using the I2C bus. I downloaded the libraries from the stm32_ov5640 GitHub page. Whenever I run the HAL_I2C_Mem_Write or HAL_I2C_Mem_Read functions, an error is returned. I read online that configuring the registers is needed before reading the chip, but even writing doesn't work.
The following is my write register function:
static int32_t OV5640_IO_ReadReg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
{
HAL_StatusTypeDef status;
uint8_t reg_addr[2];
// OV5640 uses 16-bit register addresses (big-endian)
reg_addr[0] = (Reg >> 8) & 0xFF; // High byte
reg_addr[1] = Reg & 0xFF; // Low byte
// Send register address then read data
status = HAL_I2C_Mem_Read(&hi2c1, OV5640_I2C_ADDRESS, Reg, I2C_MEMADD_SIZE_16BIT, pData, Length, HAL_MAX_DELAY); // OV5640_I2C_ADDRESS = 0x3C but I tried with 0x3C << 1 and 0x79
if (status != HAL_OK) {
return OV5640_ERROR;
}
return OV5640_OK;
}I run it using the following code
printf("Reading camera ID...\r\n");
uint8_t tmp = 0x0;
ret = OV5640_IO_ReadReg(OV5640_I2C_ADDRESS, OV5640_CHIP_ID_HIGH_BYTE, &tmp, 1);
if (ret != HAL_OK){
printf("Failed to read register");
BSP_LED_On(LED_RED);
} else {
printf("Camera ID read: SUCCESS (ID=0x%hu)\r\n", &tmp);
}Whenever I run it, it outputs the "Failed to read register line." I have connected all of the pins except the DCMI pins and the external clock pin. I soldered the internal clock jumper on as specified in the Adafruit pinout page here. The green light on the camera board is lighting up. I have tried a lot and looked through many forum posts, but nobody seems to have my exact issue since I tried with all their fixes and nothing worked. Let me know if you have anymore questions!
The link to the function on my GitHub repository is here.
Thanks in advance!!
