cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_I2C_Mem_Read returns error if used inside ISR

ssena.1514
Associate III

 

Hi,

Currently I am implementing the smbalert functionality for ltc4015 based battery charger.

But when I am using the below mentioned code(commented section) inside isr it is returning communication error.

 

 

//SMBALERT interrupt from ltc4015 to stm32l0

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)

{

HAL_StatusTypeDef ret;

uint8_t buf[1];

uint8_t read_buf_word[2];

 

smbalert_flag = 1;//set the smbalert_flag

 

//step-1

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7,GPIO_PIN_RESET);//RESET PIN cleared of PCA9546A

//HAL_Delay(1);//put some delay

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7,GPIO_PIN_SET);//RESET PIN set of PCA9546A

//HAL_Delay(1);//put some delay

 

//step-2

buf[0] = CONTROL_REG1;

ret = HAL_I2C_Master_Transmit(&hi2c1,PCA9546A_DEVICE_ADDRESS,buf,1,HAL_MAX_DELAY);//select channel 0 for i2c switch

if (ret != HAL_OK)

{

Error_Handler();

}

 

// //read limit_alerts

// ret = HAL_I2C_Mem_Read(&hi2c1,LTC4015_DEVICE_ADDRESS_READ,0x36,I2C_MEMADD_SIZE_8BIT,read_buf_word, 2,HAL_MAX_DELAY);

// if (ret != HAL_OK)

// {

// Error_Handler();

// }

// limit_alert_value = ((uint16_t)read_buf_word[0] | ((uint16_t)read_buf_word[1] << 8));

}

 

 so kindly inform me as soon as possible what could be the possible reason for this. And how to solve this problem.

 

Thanks & Regards

Satyabrata Senapati(vasmed)

10 REPLIES 10

it's over your head

If you find my answers useful, click the accept button so that way others can see the solution.