2013-10-28 02:53 AM
I work with STM32F103RBT6.
In stm32f10x.h i set #define STM32F10X_MD, it leads us to : #define SYSCLK_FREQ_72MHz 72000000 in system_stm32f10x.h. So SystemInit() function should go to SetSysClockTo72(). However on MCO pin configured as PLL/2 i see frequency 12Mhz i.e 24Mhz system clock instead of 72Mhz. What could be a problem?2013-10-28 04:45 AM
Check the code that's setting the PLL up, what settings, etc.
Check that the external oscillator is starting, and what speed it is.Check the HSE_VALUE define for the project, and if it matches the external.Use a debugger and step through the SystemInit() code.2013-10-28 05:22 AM
On HSE I see nice 8Mhz clock - it's defined in .h file.
SystemInit jumps toSetSysClockTo24(),
cant figure why. Any way it went as it went. After that i fire my own functionvoid SysClockInit(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
/* Configuration SYSCLK, HCLK, PCLK2 и PCLK1 ---------------------------*/
/* Switch on HSE */
RCC->CR |= ((uint32_t)RCC_CR_HSEON);
/* Wait for HSE ready bit or timeout*/
do
{
HSEStatus = RCC->CR & RCC_CR_HSERDY;
StartUpCounter++;
} while( (HSEStatus == 0) && (StartUpCounter != HSEStartUp_TimeOut));
if ( (RCC->CR & RCC_CR_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
/* if HSE started good */
if ( HSEStatus == (uint32_t)0x01)
{
FLASH->ACR |= FLASH_ACR_PRFTBE;
FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY);
FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_2;
/* HCLK = SYSCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSE * 9 = 72 MHz */
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE |
RCC_CFGR_PLLMULL));
RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL9);
/* Switch on PLL */
RCC->CR |= RCC_CR_PLLON;
/* wait for PLL ready bit */
while((RCC->CR & RCC_CR_PLLRDY) == 0) { }
/* choose PLL as system clock source */
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08) { }
}
else
{
/* All is bad... HSE didn't turn on... Something wrong... */
}
//return HSEStatus;
}
And 24Mhz stays on.
2013-10-28 06:24 AM
Then I guess you'll need to look into what the compiler is seeing/doing. That it's looking at file you think it is, and that the pre-processor defines passed to the compiler are what they should be.
2013-10-28 06:29 AM
Thanks. I'll look into it.