2013-07-01 04:34 AM
I'm using below settings (in
SystemInit
function) to configure a STM32F215RG MCU to work at maximum speed (120MHZ) with USB support:
RCC_DeInit(); RCC_HSICmd(ENABLE); while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET); /* Flash 3 wait state, prefetch buffer and cache ON */ FLASH_SetLatency(FLASH_Latency_3); FLASH_PrefetchBufferCmd(ENABLE); FLASH_InstructionCacheCmd(ENABLE); FLASH_DataCacheCmd(ENABLE); /* HCLK = SYSCLK */ RCC_HCLKConfig(RCC_SYSCLK_Div1); /* PCLK2 = HCLK/2 */ RCC_PCLK2Config(RCC_HCLK_Div2); /* PCLK1 = HCLK/4 */ RCC_PCLK1Config(RCC_HCLK_Div4); /* Configure the main PLL clock to 120 MHz */ RCC_PLLConfig(RCC_PLLSource_HSI, PLL_M, PLL_N, PLL_P, PLL_Q); /* Enable the main PLL */ RCC_PLLCmd(ENABLE); /* Wait till the main PLL is ready */ while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET); /* Select the main PLL as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); /* Wait till the main PLL is used as system clock source */ while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
& here are PLL config params:
#define PLL_M 16 #define PLL_N 240 #define PLL_P 2 #define PLL_Q 5
But seems there is a problem with HSI because MCU does NOT start to work after restarting.
But when I configure it to use HSE instead (with 8MHZ crystal,
PLL_M=8
) the MCU works as expected.
Is there any mistake in my configuration?
#stm32f2xx-pll-hsi-config #usb-rcc
2013-07-01 05:25 AM
The part boots with HSI running, so the chance it a) doesn't work, and b) needs switching on, are pretty slim.
You should perhaps output clocks via the MCOx pins and check them with a scope. Also, I don't think HSI is sufficiently accurate for USB usage. How are you testing that it doesn't work? Do you have some code toggling a GPIO/LED, or something outputting via a USART?2013-07-01 11:21 AM
I tested it with a toggling LED.
Seems when I modify PLL config params such that set SYSCLK to a value lower than 120MHZ (e.g 60MHZ) it works correctly, but in the user manual I didn't find anything about max CPU frequency limitation while using HSI.2013-07-01 12:02 PM
USB requires the HSE oscillator:
The USB OTG FS receives the 48 MHz ±0.25% clock from the reset and clock controller
(RCC), via an external quartz. The USB clock is used for driving the 48 MHz domain at fullspeed
(12 Mbit/s) and must be enabled prior to configuring the OTG FS core.
RM0033 rev 4 page 923 Jack Peacock2013-07-01 12:49 PM
but in the user manual I didn't find anything about max CPU frequency limitation while using HSI.
I don't believe there is, I have F2 boards running at 120 MHz from HSI here. Have you tried using something close to the original system_stm32f2xx.c with just the PLL_M, and the PLL source changed? Do you have a debugger that can step into and through SystemInit() ?