cancel
Showing results for 
Search instead for 
Did you mean: 

HSI clock and baudrate ?

antonius
Senior

Dear Members,

I changed my clock from MSI to HSI but my SPI and UART baudrate becoming wrong,

What do I miss here ?

thanks

29 REPLIES 29

On 2.097MHz :

0690X000008A65gQAC.jpg

What does USART2 look like via PA2/PA3 and the NUCLEO VCP @32 MHz?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior

On 32MHz, on UART1, I still get the same issue ??

antonius
Senior

which one is related with UART3 ? APB1 or APB2 ?

antonius
Senior

probably External crystal may help ?

antonius
Senior

USART3 register when 32MHz0690X000008A6AlQAK.jpg

antonius
Senior

Core=2097152, 2 MHz

HCLK=2097152

APB1=2097152

APB2=2097152

I can't use VCP, I have installed it as a driver, but can not see it my device driver,

I'm using Win 7 64.

I tried with external 16MHz, but it's not responding, it returned to 2.097MHz always...

I have no clues why until this level, any other ways ?

the stable setting only :

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
 
  /**Configure the main internal regulator output voltage 
  */
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
  /**Initializes the CPU, AHB and APB busses clocks 
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
  RCC_OscInitStruct.MSIState = RCC_MSI_ON;
  RCC_OscInitStruct.MSICalibrationValue = 0;
  RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_5;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
  /**Initializes the CPU, AHB and APB busses clocks 
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
 
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  {
    Error_Handler();
  }
}

Is it related with : RCC_HSICALIBRATION_DEFAULT ?