-
STM32F401RCTx SPI and I2C clock running at double frequency, when using external XTAL. Problem description: Hardware description: The test examples in this issue report used on device: STM32CubeProgrammer: Arduino: Software used during these tests: STM32CubeProgrammer v2.16.0 (required by Arduino IDE) Arduino IDE 2.3.2 Arduino IDE Board Settings: Code and test procedure description: Thank you for reading. ` #include <Wire.h> TwoWire Wire1(PB7, PB6); /* system clock STM32F401RCT6 with external 16Mhz XTAL */ void SystemClock_Config(void) // GPIO Ports Clock Enable // Configure GPIO pin : PA8 RCC_OscInitTypeDef RCC_OscInitStruct = {}; /** Configure the main internal regulator output voltage __HAL_RCC_TIM10_CLK_ENABLE(); /** Initializes the RCC Oscillators according to the specified parameters
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) // MCO1 op pin PA8 /* system clock STM32F401RCT6 with external 16Mhz XTAL, but with I2C and SPI clock correction */ void SystemClock_Config_RCC_HCLK_DIV4(void) /** Configure the main internal regulator output voltage __HAL_RCC_TIM10_CLK_ENABLE(); /** Initializes the RCC Oscillators according to the specified parameters
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) // MCO1 op pin PA8 void setup(void) // Enable MCO1 on pin PA8 -> 21Mhz if (false)
} // Led Serial.begin(115200); delay(1000); Serial.println("Start"); // I2C1 Wire1.begin(); // Redo Clock settings but adapt the I2C and SPI clock to correct values void loop(void) Wire1.beginTransmission(0x71); delay(500); Serial.println("Turn"); // Toggle LED ` |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi @wltue So you have to redefine it using hal_conf_extra.h or build_opt.h |
Beta Was this translation helpful? Give feedback.
-
Hello fpistm |
Beta Was this translation helpful? Give feedback.
Hi @wltue
No issue in the core.
It's simply that you used a 16MHz HSE and the default value is 8MHz
Arduino_Core_STM32/system/STM32F4xx/stm32f4xx_hal_conf_default.h
Line 100 in 7095e16
So you have to redefine it using hal_conf_extra.h or build_opt.h