cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with configuring I2C1 (PB6 SCL, PB7 SDA) and specific GPIO outputs (PA5, PA6) on STM32L432KCUx, it may be bug, help needed.

DamianTadzikB
Associate II

Hi, i've been building self balancing robot, so i needed quite lot of periphelias to be working together, they are: I2C, EXTI's, two Timers in encoder mode, Timer in PWM generation mode and GPIO outputs.

I'm using STM32CubeIDE 1.9.0., and STM32L432KC nucleo board

I've been enabling those peripherals one by one in cubeMX, and every time when i generated code i've checked if it works. (It all went fine, MPU6050, EEPROM, and LCD connected to I2C bus worked well, so i assume my hardware setup is good)

Unfortunately, after enabling PA6 and/or PA5 as GPIO output, my I2C1_SDA and I2C1_SCL lines are immediately pulled down after powering up the device.

That's weird behaviour because I2C1 has nothing in common with pins PA6 and PA5.

Maybe i missed something in documentation or in chip errata.

I posted the code (whole project) on GitHub because it's easy to see changes in the code between commits, it helped me a lot in finding this bug source (i suppose lol). I apologize if the names of the commits are not intuitive enough. Interesting things are in commits 5 to 15.

Commits · DamianTadzik/robo_balance (github.com)

For me it looks like in function void MX_GPIO_Init(void), 9th line of code somehow puts my I2C1 pins in GPIO_PIN_RESET mode. For example you can see that this line differs between commit 14 and 15 (14th commit code works, but 15th not)

void MX_GPIO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();
 
  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOA, EN_L_2_Pin|EN_L_1_Pin|EN_R_1_Pin|EN_R_2_Pin, GPIO_PIN_RESET);
 
  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_RESET);
 
  /*Configure GPIO pins : PAPin PAPin PAPin PAPin */
  GPIO_InitStruct.Pin = EN_L_2_Pin|EN_L_1_Pin|EN_R_1_Pin|EN_R_2_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  /*Configure GPIO pins : PAPin PAPin PAPin */
  GPIO_InitStruct.Pin = BTN_OK_Pin|BTN_NO_Pin|BTN_LE_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  /*Configure GPIO pin : PtPin */
  GPIO_InitStruct.Pin = LD3_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(LD3_GPIO_Port, &GPIO_InitStruct);
  /*Configure GPIO pin : PtPin */
  GPIO_InitStruct.Pin = BTN_RI_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(BTN_RI_GPIO_Port, &GPIO_InitStruct);
  /* EXTI interrupt init*/
  HAL_NVIC_SetPriority(EXTI9_5_IRQn, 12, 0);
  HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
  HAL_NVIC_SetPriority(EXTI15_10_IRQn, 12, 0);
  HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
}

In my case i can live without using PA5 and PA6 as GPIOs, simply i will use different pins as GPIO outputs, it may be one of: PB0 PB1 PB3 PB4 but i thought it is worth posting.

0693W00000Y8W7VQAV.pngI hope, my english wasn't so hard to read, and apologize for any language mistakes.

Thanks in advance,

Best regards DB

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

Check the board schematics.

https://www.st.com/en/evaluation-tools/nucleo-l432kc.html#cad-resources

You might have to open some solder bridges.

hth

KnarfB

View solution in original post

3 REPLIES 3
KnarfB
Principal III

Check the board schematics.

https://www.st.com/en/evaluation-tools/nucleo-l432kc.html#cad-resources

You might have to open some solder bridges.

hth

KnarfB

Oh, i might have overlooked this... i'll give an update in few hours but it seems like this is the case.

Thank you,

DB

Yup, there are solder bridges SB16 and SB18, and they link PA6 with PB6 and PA5 with PB7 respectfully.

I overlooked it, but I also didn't expect the factory solder bridge to be in such a place.

Thank you for help, i appreciate it very much,

Best regards

DB