AnsweredAssumed Answered

Nucleo-STM32F303K8 board

Question asked by William Huang on Dec 22, 2016
Latest reply on Dec 23, 2016 by William Huang

Hi, I just got the stm32f303k8 nucleo board to play with! I'm trying to enable the HSE in order for the board to use the on-board oscillator (X2), however it doesn't seem like it wants to turn ON. I'm using Keil as the IDE and here's my code:

#include "stm32f303x8.h"

void HSEConfig(unsigned char status);

int main(void)
{
    HSEConfig(1);
   
    for(;;);
    return 0;
}

void HSEConfig(unsigned char status)
{
    if(status)
    {
        // Let System Clock to use HSE
        RCC->CFGR |= RCC_CFGR_SW_HSE;
        // Enable High Speed External Oscilator
        // and wait for the clock to stabilize
        RCC->CR |= RCC_CR_HSEON;
        while( (RCC->CR & RCC_CR_HSERDY) == 0);

        // Disable HSI
        RCC->CR &= ~RCC_CR_HSION;
        while(RCC->CR & RCC_CR_HSIRDY);

    }
}

Outcomes