Why I2C pins are always low in STM32F0?
Hello, I have a SMT32F042, i'm trying to use I2C. I used STM32 CubeMX to generale a new blank project with only i2c (see attached). I2C on non standard pins.
The problem is that they always stay low, it does not transfer anything.
This is what I captured with the logic analyzer, after starting the debug, it goes low.
I attach the code, but it is really standard: https://pastebin.com/ijX9RLEG
I tried also to configure everything as output pin with external pull up (9,5k) and open drain... it works, so my pull up resistor are working.
I really don't know what to check next. THe same come with nucleo works perfectly.
Thank you,
UPDATE 1:
I tried with i2c1 normal pins (PF0 and PF1), and it worked. For my configuration (PB14+PB13) the result is still the same. I ended up that maybe is a but in stm32cube with setting alternate function. Anybody can see something strange?
In addition with main.c code, I am posting here the hal_msp.c code involved:
/**
* @brief I2C MSP Initialization
* This function configures the hardware resources used in this example
* @param hi2c: I2C handle pointer
* @retval None
*/
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hi2c->Instance==I2C1)
{
/* USER CODE BEGIN I2C1_MspInit 0 */
/* USER CODE END I2C1_MspInit 0 */
__HAL_RCC_GPIOB_CLK_ENABLE();
/**I2C1 GPIO Configuration
PB13 ------> I2C1_SCL
PB14 ------> I2C1_SDA
*/
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* Peripheral clock enable */
__HAL_RCC_I2C1_CLK_ENABLE();
/* USER CODE BEGIN I2C1_MspInit 1 */
/* USER CODE END I2C1_MspInit 1 */
}
}