2015-12-30 02:14 AM
Hello,
I've made a project based on stm32f103c8 mcu with keil4, init functions were generated in cubemx, The problem is MCU system clock: it is 8 MHz with any AHB Prescaler. System clock source = HSE, Crystal 8MHz PLL OFF HCLK = 8 MHz with ANY AHB prescaler :( void SystemClock_Config(void)void SystemClock_Config(void)
{ RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_PeriphCLKInitTypeDef PeriphClkInit; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.LSEState = RCC_LSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; HAL_RCC_OscConfig(&RCC_OscInitStruct); RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0); PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_ADC; PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV2; HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); } Tested: RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; DIV2, DIV4, DIV8. All the time i got 8 MHz system BTW using manual correction is OK, working code, but cannot use it in production: SystemClock_Config(); RCC->CFGR|=0x90; // SYSCLK divided by 4 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); HAL_Delay(100); #stm32f103 #stm32cube #bug2015-01-01 01:20 AM
IOC file
________________ Attachments : carAlarmTest.ioc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Htjq&d=%2Fa%2F0X0000000aWN%2FrpAtdiDI8fLg1dO452pY61snMH8Wxh.1dfXmzr2CupI&asPdf=false2015-12-30 03:07 AM
Hi ryabov.alexander
I cannot reproduce your issue,I display the SystemCoreClock variable in the KEIL watch and I get correct frequency for each AHB divider. For the manual correction that you did: RCC->CFGR|=0x90, it means that you use HSI instead of HSE (0x95).Could you please share your .ioc file for check?-Syrine-2015-12-31 09:27 AM
For the manual correction that you did: RCC->CFGR|=0x90, it means that you use HSI instead of HSE (0x95).
No, it is not. ''|='' is not ''=''Could you please share your .ioc file for check?
sure, after holiday will post it