Now what a fun: Unboxed my brand new STM32F3-Discovery, plugged it in — sweet blinking rapture. Compiled my first demo program, played around with the timers, all was so good. Until I had a closer look at the system clock speed: 8 MHz it said. So I dug into the unknown grounds of STM32F3 development, ended up in the generated firmware’s system initialization function in system_stm32f30x.c
— which looks like this:
static void SetSysClock(void) { __IO uint32_t StartUpCounter = 0, HSEStatus = 0; /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------*/ /* Enable HSE */ RCC->CR |= ((uint32_t)RCC_CR_HSEON); /* Wait till HSE is ready and if Time out is reached exit */ do { HSEStatus = RCC->CR & RCC_CR_HSERDY; StartUpCounter++; } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); if ((RCC->CR & RCC_CR_HSERDY) != RESET) { HSEStatus = (uint32_t)0x01; // all good } else { HSEStatus = (uint32_t)0x00; // nah. } /* ... */
I did so, only to find out that HSEStatus
never switched to 0x01
because the RCC_CR_HSERDY
flag was never asserted in the first place.
Obviously no one else in the whole wide web had trouble with this. Cold water? Let’s dive!
Some dude at the ST forums pointed me to the trick to output the RCC clock signal to the board’s PA8 pin, which I did like so:
void InitializeMCOGPIO() { RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); /* Configure MCO (PA8) */ GPIO_InitTypeDef gpioStructure; gpioStructure.GPIO_Pin = GPIO_Pin_8; gpioStructure.GPIO_Speed = GPIO_Speed_50MHz; gpioStructure.GPIO_Mode = GPIO_Mode_AF; gpioStructure.GPIO_OType = GPIO_OType_PP; gpioStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(GPIOA, &gpioStructure); /* Output HSE clock on MCO pin (PA8) */ RCC_MCOConfig(RCC_MCOSource_HSE); }
Turned out … well, nothing. Flatline on that pin. So I took my multimeter and went upstream from the oscillator pins. Solder bridge SB12, of course bridged, working fine, SB17 open as requested, and then — silence on RB48. No beeps on my meter, no value, just plain high impedance.
To make a long story short: That 100 Ω resistor was borked, so I replaced it with some spare parts of an old scanner board I had floating around in the to-do stash. I’m not exactly known for massive soldering experience, but this video helped a lot here.
Final result:
Ugly but effective. Works like a charm now.