cancel
Showing results for 
Search instead for 
Did you mean: 

Setting the Clocks on the STM32F105 for I2C

NCook.9
Associate

Hi all

I am struggling to get the I2C up and running. I set the clocks and initialisation up in CubeMX (latest version) and when debugging the code I keep getting the pclk1 variable coming back with 1000000 which is below the limit so I get a HAL_ERROR.

The APB1 Peripheral Clock is set at 36 MHz, I am using a 25 MHz HSE crystal. All other peripherals are running fine.

I am clearly setting the clocks up incorrectly. As when I do a MasterWrite I don't see anything on the line.

Anyone with any ideas.

Regards

Nick

/* Get PCLK1 frequency */

 pclk1 = HAL_RCC_GetPCLK1Freq();

 /* Check the minimum allowed PCLK1 frequency */

 if (I2C_MIN_PCLK_FREQ(pclk1, hi2c->Init.ClockSpeed) == 1U)

 {

  return HAL_ERROR;

 }

0 REPLIES 0