AnsweredAssumed Answered

stm32F071 + STOP MODE + wakeup + HSI48 = hard fault

Question asked by Kok.Henk on Apr 5, 2016
Latest reply on Apr 5, 2016 by FTITI.Walid
For a wearable product we're working on a device that wakes up 160 times a second (for now, will later be reduced to ~10 times per second), does it's thing, communicates with a host and remains in STOP mode for the rest of the time. Because it is battery operated, current consumption is a big issue.

We are not yet certain whether using the HSI48 (instead of HSI at 8 MHz) will have the effect on the average current that we want (if the amount of awake time is linear to the clock speed, then it would as HSI48 goes 6 times as fast with 4.6 times as much current) but while investigating the usage of the HSI48 we ran into an issue.

It seems to be that some hardware samples are more susceptible than others, but what we see, is that after waking up from sleep and going back to the HSI48 results in a hard fault a few instructions after the change to HSI48 is made. I copied code for the change to HSI48 from the STM32F0xx_HAL files, and as far as I can see we're doing everything right. After the wakeup, we do the following:

    /* Enable HSI48 */
    __HAL_RCC_HSI48_ENABLE();
 
    /* Wait till HSI48 is ready */  
    while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSI48RDY) == RESET)
    {
        /* Wait for 48MHz RC clock to be stable */
    }
    /* change to HSI48 */
    MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, RCC_SYSCLKSOURCE_HSI48);
    while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_HSI48)
    {
        /* wait till clock accepted as sysclk */
    }

Is this something that rings a bell to anyone?

Outcomes