ADPD Data Collection problem

Hello,

I am trying a simple I2C Driver to fetch data from ADPD 1080 to my STM32L4 Discovery Kit and I am using STM System Workbench IDE.

uint8_t clk_reg_data[3] = {0x4B, 0x26, 0x92};
uint8_t program_mode_reg_data[3] = {0x10, 0x00, 0x01};
uint8_t sampling_mode_reg_data[3] = {0x10, 0x00, 0x02};
uint8_t slotB_enable_reg_data[3] = {0x11, 0x10, 0x20};
uint8_t ledX1_enable_reg_data[3] = {0x14, 0x05, 0x54};
uint8_t slotB_halt_sampling_reg_data[3] = {0x5F, 0x00, 0x04};
uint8_t slotB_resume_sampling_reg_data[3] = {0x5F, 0x00, 0x00};
uint8_t rx_data_reg = 0x68;
uint8_t rx_data[10];
memset(rx_data, 0, sizeof(rx_data));
HAL_Init();
SystemClock_Config();

I2Cx_Init(&hI2cHandler);

// for(i = 0; i < 100; i++)
// {
if(HAL_I2C_Master_Transmit(&hI2cHandler, hI2cHandler.Init.OwnAddress1, (uint8_t *)clk_reg_data, 3, (uint32_t)100) != HAL_OK)
{
printf("error\n");
}
while (HAL_I2C_GetState(&hI2cHandler) != HAL_I2C_STATE_READY)
{
}

if(HAL_I2C_Master_Transmit(&hI2cHandler, hI2cHandler.Init.OwnAddress1, (uint8_t *)program_mode_reg_data, 3, (uint32_t)100) != HAL_OK)
{
printf("error\n");
}
while (HAL_I2C_GetState(&hI2cHandler) != HAL_I2C_STATE_READY)
{
}

if(HAL_I2C_Master_Transmit(&hI2cHandler, hI2cHandler.Init.OwnAddress1, (uint8_t *)slotB_enable_reg_data, 3, (uint32_t)100) != HAL_OK)
{
printf("error\n");
}
while (HAL_I2C_GetState(&hI2cHandler) != HAL_I2C_STATE_READY)
{
}

if(HAL_I2C_Master_Transmit(&hI2cHandler, hI2cHandler.Init.OwnAddress1, (uint8_t *)ledX1_enable_reg_data, 3, (uint32_t)100) != HAL_OK)
{
printf("error\n");
}
while (HAL_I2C_GetState(&hI2cHandler) != HAL_I2C_STATE_READY)
{
}


if(HAL_I2C_Master_Transmit(&hI2cHandler, hI2cHandler.Init.OwnAddress1, (uint8_t *)sampling_mode_reg_data, 3, (uint32_t)100) != HAL_OK)
{
printf("error\n");
}
while (HAL_I2C_GetState(&hI2cHandler) != HAL_I2C_STATE_READY)
{
}

while(1)
{
if(HAL_I2C_Master_Transmit(&hI2cHandler, hI2cHandler.Init.OwnAddress1, (uint8_t *)slotB_halt_sampling_reg_data, 3, (uint32_t)100) != HAL_OK)
{
printf("error\n");
}
while (HAL_I2C_GetState(&hI2cHandler) != HAL_I2C_STATE_READY)
{
}


//capture data

if(HAL_I2C_Master_Transmit(&hI2cHandler, hI2cHandler.Init.OwnAddress1, (uint8_t *)&rx_data_reg, 1, (uint32_t)100) != HAL_OK)
{
printf("error\n");
}
while (HAL_I2C_GetState(&hI2cHandler) != HAL_I2C_STATE_READY)
{
}

if(HAL_I2C_Master_Receive(&hI2cHandler, hI2cHandler.Init.OwnAddress1, (uint8_t *)rx_data, 8, (uint32_t)500) != HAL_OK)
{
printf("error\n");
}
while (HAL_I2C_GetState(&hI2cHandler) != HAL_I2C_STATE_READY)
{
}

//restart capture

if(HAL_I2C_Master_Transmit(&hI2cHandler, hI2cHandler.Init.OwnAddress1, (uint8_t *)slotB_resume_sampling_reg_data, 3, (uint32_t)100) != HAL_OK)
{
printf("error\n");
}
while (HAL_I2C_GetState(&hI2cHandler) != HAL_I2C_STATE_READY)
{
}

This is my driver code.

The problem i am facing is whenever i directly run the code the sensor data will not be displayed and it says 0 for all 8 bytes (In one read 8 bytes of data is being fetched).

But when i go step wise with step over function in debug environment i get the results into my rx_data[ ]. I am not understanding what is going on in this. Is it a delay problem? If so where should the delay be added and how much of it is to be added?

Any suggestions or hints will be really helpful.

Thanks & Regards,
Sudeep R J