OSC_IN and OSC_EN wrong initialization order
Hi!
I have a board with an external oscillator. The oscillator would not start, and I spent a few hours debugging the issue only to find out the automatically generated code initialized the clock and the OSC_EN pin in the wrong order!
relevant ioc lines:
PC14-OSC32_IN\ (PC14).Mode=HSE-External-Clock-Source
PC14-OSC32_IN\ (PC14).Signal=RCC_OSC_IN
PC15-OSC32_OUT\ (PC15).Mode=OSC enable
PC15-OSC32_OUT\ (PC15).Signal=RCC_OSC_ENthe generated code:
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ADC1_Init();
MX_TIM1_Init();
/* USER CODE BEGIN 2 */
...
void SystemClock_Config(void)
{
...
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
...
static void MX_GPIO_Init(void)
{
...
/*Configure GPIO pin : PC15 */
GPIO_InitStruct.Pin = GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF1_OSC;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);Note `HAL_RCC_OscConfig` will wait until HSERDY but it will be never ready if since PC15 is not configured as OSC_EN yet.
