Skip to main content
Visitor II
February 1, 2022
Question

i2c2

  • February 1, 2022
  • 1 reply
  • 858 views

I'm working with the DevBoard from Myir MYD-YA-157C which has the stm32mp157 MPU. I'm trying to chech the i2c from the M4 in the Engineering mode and have a problem.

When I tied the I2C_TwoBoards_ComIT, it works. At least it generates the I2C5_ER_IRQ.

But when I move to the i2c2 or any other with pins that I have out, it doesn't work. Just doesn't do anything, doesn't send anyithng and doesn't generate an interrupt.

It is a simple test without any other peripherial enabled.

Could you help me what is wrong.

static void MX_I2C2_Init(void)
{
 
 hi2c2.Instance = I2C2;
 hi2c2.Init.Timing = 0x00701837;
 hi2c2.Init.OwnAddress1 = 783;
 hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_10BIT;
 hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
 hi2c2.Init.OwnAddress2 = 0;
 hi2c2.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
 hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
 hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
 if (HAL_I2C_Init(&hi2c2) != HAL_OK)
 {
 Error_Handler();
 }
 
 /**Configure Analogue filter 
 */
 if (HAL_I2CEx_ConfigAnalogFilter(&hi2c2, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
 {
 Error_Handler();
 }
 
 /**Configure Digital filter 
 */
 if (HAL_I2CEx_ConfigDigitalFilter(&hi2c2, 0) != HAL_OK)
 {
 Error_Handler();
 }
 
 /**I2C Fast mode Plus enable
 */
 HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C2);
}
 
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
{
 
 GPIO_InitTypeDef GPIO_InitStruct;
 if(hi2c->Instance==I2C2)
 {
 /* USER CODE BEGIN I2C2_MspInit 0 */
 if(IS_ENGINEERING_BOOT_MODE())
 {
 RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInitStruct;
 
 /*##-1- Configure the I2C clock source #*/
 RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C12;
 RCC_PeriphCLKInitStruct.I2c12ClockSelection = RCC_I2C12CLKSOURCE_HSI;
 HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
 }
 /* USER CODE END I2C2_MspInit 0 */
 
 /**I2C2 GPIO Configuration
 PZ6 ------> I2C2_SCL
 PZ7 ------> I2C2_SDA
 */
 GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
 GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 GPIO_InitStruct.Alternate = GPIO_AF3_I2C2;
 PERIPH_LOCK(GPIOZ);
 HAL_GPIO_Init(GPIOZ, &GPIO_InitStruct);
 PERIPH_UNLOCK(GPIOZ);
 /* Peripheral clock enable */
 __HAL_RCC_I2C2_CLK_ENABLE();
 /* I2C2 interrupt Init */
 HAL_NVIC_SetPriority(I2C2_EV_IRQn, DEFAULT_IRQ_PRIO, 0);
 HAL_NVIC_EnableIRQ(I2C2_EV_IRQn);
 HAL_NVIC_SetPriority(I2C2_ER_IRQn, DEFAULT_IRQ_PRIO, 0);
 HAL_NVIC_EnableIRQ(I2C2_ER_IRQn);
 /* USER CODE BEGIN I2C2_MspInit 1 */
 
 /* USER CODE END I2C2_MspInit 1 */
 }
 
}

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    March 16, 2022

    Hi @SergeyBlagodarnyy​ ,

    Sorry to come late on this post.

    Did you find solution by yourself ?

    Where do you stand ?

    Olivier