AnsweredAssumed Answered

HSE RDY high without HSE clock ?

Question asked by Aditya Mall on Apr 29, 2018
Latest reply on Apr 29, 2018 by Aditya Mall

I am using the Nucleo-64 board F401RE, as the name suggest comes with STM32F401RE.

The board doesn't have an external clock (X3 mentioned on the board) and still the HSE RDY register gets enabled  , which is actually hardware enabled as per datasheet.

 

int main(void)
{
    RCC_TypeDef *pRCC;
    pRCC = RCC;
    /** 1) Turn on the HSE Oscillator, by accessing the RCC clock control register (RCC_CR)
        * 2) Select HSE as the system clock, by accessing the RCC clock configure register (RCC_CFGR)
    */
    
    //1) Turning on RCC_CR by enabling 16 bit.
    pRCC->CR |= (1 << 16);
    
    /** We need to wait after the HSE register is enabled for the HSE to become stable,
      * This status is show by HSE RDY (Ready) register which enabled by the MCU. (17th bit).
      */
    //wait!! till HSE RDY becomes 1
    while(! (pRCC->CR & (1 << 17)) );           HSE gets enabled and the code gets out of the loop

 

    //2) Toggling the SW register to [0 1] (SW1 and SW0) on RCC_CFGR for switching HSE as system clock
    pRCC->CFGR &= ~(0x3 << 0);    //clearing the first two bits sw1 and sw0, best practice
    pRCC->CFGR |= (0x1 << 0);        //As per datasheet 01:HSE enable, setting first bit as 0
    
    return 0;
}

 

nucleo-64 nucleo-f401re hse issue

Outcomes