ISL91302BIIZ I2C Communication unable to establish using stm32 mcu

I am using STM32L496QGI6P mcu to communicate with the ISL91302BIIZ-TR5931 PMIC.

Following is my relevant code which uses i2c3 (pg7/pg8 pins on mcu for scl/sda), I am also initializing GPIO PE1 as EN pin for PMIC. I am at the end scanning the i2c3 bus to see if I can find any device but I am not able to get a communication on any of the I2C addresses.

else if(hi2c->Instance==I2C3)

{

/* USER CODE BEGIN I2C3_MspInit 0 */

/* USER CODE END I2C3_MspInit 0 */

/** Initializes the peripherals clock

*/

PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_I2C3;

PeriphClkInit.I2c3ClockSelection = RCC_I2C3CLKSOURCE_PCLK1;

if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)

{

Error_Handler();

}

__HAL_RCC_GPIOG_CLK_ENABLE();

/**I2C3 GPIO Configuration

PG7 ------> I2C3_SCL

PG8 ------> I2C3_SDA

*/

GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8;

GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;

GPIO_InitStruct.Pull = GPIO_PULLUP;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF4_I2C3;

HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

/* Peripheral clock enable */

__HAL_RCC_I2C3_CLK_ENABLE();

/* USER CODE BEGIN I2C3_MspInit 1 */

/* USER CODE END I2C3_MspInit 1 */

}

void I2C3_ScanBus(void) {

printf("Scanning I2C3 bus...\n");

//Reinit_I2C3();

//__HAL_RCC_I2C3_CLK_ENABLE();

for (uint8_t addr = 0x03; addr <= 0x77; addr++) {

// Shift address to 8-bit form (HAL expects 8-bit address)

if (HAL_I2C_IsDeviceReady(&hi2c3, addr << 1, 2, 10) == HAL_OK) {

cmis_page0[0] = addr;

}

HAL_Delay(10);

}

printf("Scan complete.\n");

}


int main(void)

{

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */

HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */

SystemClock_Config();

PeriphCommonClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */

MX_GPIO_Init();

MX_I2C4_Init();

MX_I2C2_Init();

MX_ADC1_Init();

MX_ADC2_Init();

MX_ADC3_Init();

__HAL_RCC_SPI1_CLK_ENABLE();

MX_SPI1_Init();

__HAL_RCC_I2C2_CLK_ENABLE();

__HAL_RCC_I2C4_CLK_ENABLE();

HAL_GPIO_WritePin(GPIOG, GPIO_PIN_6, GPIO_PIN_RESET);

HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);

HAL_Delay(1000);

HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_SET);

HAL_Delay(1000);

MX_I2C3_Init();

__HAL_RCC_I2C3_CLK_ENABLE();

I2C3_ScanBus();

void SystemClock_Config(void)

{

RCC_OscInitTypeDef RCC_OscInitStruct = {0};

RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

/** Configure the main internal regulator output voltage

*/

if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)

{

Error_Handler();

}

/** Initializes the RCC Oscillators according to the specified parameters

* in the RCC_OscInitTypeDef structure.

*/

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;

RCC_OscInitStruct.MSIState = RCC_MSI_ON;

RCC_OscInitStruct.MSICalibrationValue = 0;

RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

Error_Handler();

}

/** Initializes the CPU, AHB and APB buses clocks

*/

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)

{

Error_Handler();

}

}

/**

* @brief Peripherals Common Clock Configuration

* @retval None

*/

void PeriphCommonClock_Config(void)

{

RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

/** Initializes the peripherals clock

*/

PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;

PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_PLLSAI1;

PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;

PeriphClkInit.PLLSAI1.PLLSAI1M = 1;

PeriphClkInit.PLLSAI1.PLLSAI1N = 8;

PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV2;

PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2;

PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2;

PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_ADC1CLK;

if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)

{

Error_Handler();

}

}

static void MX_I2C3_Init(void)

{

/* USER CODE BEGIN I2C3_Init 0 */

/* USER CODE END I2C3_Init 0 */

/* USER CODE BEGIN I2C3_Init 1 */

/* USER CODE END I2C3_Init 1 */

hi2c3.Instance = I2C3;

hi2c3.Init.Timing = 0x10030D09;

hi2c3.Init.OwnAddress1 = 0;

hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;

hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;

hi2c3.Init.OwnAddress2 = 0;

hi2c3.Init.OwnAddress2Masks = I2C_OA2_NOMASK;

hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;

hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;

if (HAL_I2C_Init(&hi2c3) != HAL_OK)

{

Error_Handler();

}

/** Configure Analogue filter

*/

if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE) != HAL_OK)

{

Error_Handler();

}

/** Configure Digital filter

*/

if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN I2C3_Init 2 */

//HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C3);

/* USER CODE END I2C3_Init 2 */

}

static void MX_GPIO_Init(void)

{

/* USER CODE BEGIN MX_GPIO_Init_1 */

/* USER CODE END MX_GPIO_Init_1 */

GPIO_InitTypeDef GPIO_InitStruct = {0};

/* GPIO Ports Clock Enable */

__HAL_RCC_GPIOE_CLK_ENABLE();

__HAL_RCC_GPIOC_CLK_ENABLE();

__HAL_RCC_GPIOF_CLK_ENABLE();

__HAL_RCC_GPIOG_CLK_ENABLE();

HAL_PWREx_EnableVddIO2();

__HAL_RCC_GPIOA_CLK_ENABLE();

__HAL_RCC_GPIOD_CLK_ENABLE();

__HAL_RCC_GPIOB_CLK_ENABLE();

GPIO_InitStruct.Pin = GPIO_PIN_1;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

Can you help to check if the initialization sequence for PMIC is correct and if I am missing setting anything on PMIC before which I will be able to communicate with PMIC using I2C.

Parents Reply
  • Hello Avinash,

    Thanks for the response. Can you please let me know the sequence to turn on the PMIC (in terms of Enable or any other pins) before which I2C communication with PMIC is available. 

    Also, can you confirm that I can use STM32 MCU to communicate with this PMIC. Do I need any other driver or HAL layer to communicate with it other than the generic HAL for I2C.

    Thanks!

Children