Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


Sleep mode is not reducing power consumption

I can’t see what I’m doing wrong. The processor seems to be going to sleep, but the current remains the same.

Here is the sleep code:


~
~
int sleep(void)
{
    TIM_HandleTypeDef tim;
    uint32_t savedier = 0;

    // Reduce clock to 1 MHz
    SystemClock_Config_NOPLL_48M_100K(RCC_MSIRANGE_4);
    // Go to low-power run mode
    HAL_PWREx_EnableLowPowerRunMode();

    tim.Instance = TIM1;
    if (0 != (TIM1->CR1 & TIM_CR1_CEN))   // Turn timer off  This works!
    {
        ++savedier;
        HAL_TIM_Base_Stop_IT(&tim);
    }
    last_isr = 0xFF;
    wakeup_isr = 0;
    w_cnt = 0;

    // Request to enter SLEEP mode
    do
    {
        HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
        ++w_cnt;
    } while (0 == wakeup_isr);

    SetSysClock();
    HAL_PWREx_DisableLowPowerRunMode();
    if (0 != savedier)
        HAL_TIM_Base_Start_IT(&tim);

    return last_isr;
}
~
~


The system has FreeRTOS, the Hal timer is set to TIM1.
In the stm32l4xx_it.c I set last_isr to the interrupt position and wakeup_isr to 1 if this ISR is suppose to wake us up from sleep.

I do this because I can’t stop FreeRTOS’s system ticks and other service interrupts. I have created code that turned off those interrupts, but FreeRTOS would not work when I turned them back on.

But even with FreeRTOS running occationally, I should see some reduction in current consumption, but I see none. Not even a little.

I’ve been looking for manuals, but I can’t find anything that says what you should do to get it into low power, only what gets turned off and on and theory of operation.

I found out about the less than 2MHz and lower-power mode from comments in the HAL_PWR_EnterSLEEPMode routine.

I’ve done this before, on many different processors. Don’t know why I can’t get it to work here.

-Matt

Soon after posting this I started having build problems (see the ‘No Symbol Table’ post)

To fix that I started a new project and copied all the .c and .h files over.

Now it works (both compiler and power saving).

I think what is happening is that I modify the project with Cube while ac6 is running. As a result the .project files will become corrupt and have these strange results.

Since then I always close ac6 when running (or at least saving) with Cube. And so far I have not seen these weird build errors.

As a side note: If anyone knows how to ‘shutdown’ FreeRTOS while sleeping I would love to hear it.
Currently I have a flag I set in the interrupt routine for any interrupt I want to break out of sleep. In the sleep code I have a do while loop looking for the flag. If not seen I just re-enter sleep mode. As a result it wakes up every 1ms (to service FreeRTOS).

I don’t really want to do Tickless because I want to force the sleep mode.

I have tried turning off the system tick and restarting it, but FreeRTOS would not operate properly when I did that (even though that’s what we do in our current products - but they are an older version of FreeRTOS).

-Matt