Post Go back to editing

Initialization of I2C communication between ADV7613 and STM32

Category: Datasheet/Specs
Product Number: ADV7613

Hello Team,

I am implementing I2C communication between STM32 and ADV7613 with HAL API's available in STM32CubeIDE, I am using target address 0x98 to access IO Map and want to read/write to IO map register address like 0x01 for Primary mode configuration, but I could not be able to establish an I2C communication. Below is the code snippet I have used:

#define ADV7613_IOMAP_ADDR     0x98<<1

uint16_t ADV7613_PRIM_MODE_ADDR = 0x01;
uint16_t ADV7613_PRIM_MODE_DATA = 0;

if(HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)ADV7613_IOMAP_ADDR, &ADV7613_PRIM_MODE_ADDR, 1, 1000) == HAL_OK){
if(HAL_I2C_Master_Receive(&hi2c1, (uint16_t)ADV7613_IOMAP_ADDR, &ADV7613_PRIM_MODE_DATA, 1, 1000) == HAL_OK){
HAL_Delay(1000);
}
}

Kindly please help me, if I am accessing target address in a correct way and what are the correct steps I need to be follow to setup I2C communication.

Regards,

RupeshK

  • Hi,

        Please let us know, Is there any intention for left shifting the IO map address (98<<1) ?

    Thanks,

    Poornima

  • Hi,

    In I2C communication the first seven bits of the "address byte" contains the slave address, whereas the last bit is a read/write bit. 0 is write and 1 is read. The target device 7 bits address value must be shifted to the left before calling the HAL_I2C_Master_Transmit API. I understand that ADV7613_PRIM_MODE_ADDR and ADV7613_PRIM_MODE_DATA should be uint8_t data type. Below are the details of API:

    /**
    * @brief Transmits in master mode an amount of data in blocking mode.
    * @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
    * the configuration information for the specified I2C.
    * @param DevAddress Target device address: The device 7 bits address value
    * in datasheet must be shifted to the left before calling the interface
    * @param pData Pointer to data buffer
    * @param Size Amount of data to be sent
    * @param Timeout Timeout duration
    * @retval HAL status
    */
    HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
    uint16_t Size, uint32_t Timeout)

    Please let me know what is the correct way to access the target device ADV7613.

    Regards,

    Rupesh

  • Hi,

      Kindly note that, Our script use 8-bit addressing if incase your target device except 7 bit address you would need to right shift the 8-bit address by one to get into a 7-bit addressing.

     If your software/tool is using 7-bit I2C address, In that case, we need to right shift the 8 bit map address to one So you should use 0x4C to access the IO map address.

    For example:    0x98   IO Map   –   8-bit address 
                             0x98>>1 =0x4C –  7-bit address
    Thanks,
    Poornima