Tx_LowPower Application Description

This application provides an example of Azure RTOS ThreadX stack usage, it shows how to develop an application using ThreadX LowPower feature. It demonstrates how to configure the LowPower feature of Azure RTOS ThreadX stack. In addition, it shows how to use ThreadX MACRO related to the LowPower feature. The main entry function tx_application_define() is then called by ThreadX during kernel start, at this stage, the application creates 1 thread and 1 semaphore:

When the “MainThread” is in suspended state, waiting for the ‘Semaphore’, the system is in idle state and the scheduler decides to enter in low power mode by calling the TX_LOW_POWER_USER_ENTER that makes the system enter the stop mode via the HAL_PWR_EnterSTOPMode() API.

As soon as the user button is pressed, the ‘Semaphore’ is released, and the ‘MainThread’ passes in Active state. The scheduler exits the stop mode by calling the TX_LOW_POWER_EXIT. In system STOP mode, all I/O pins keep the same state as in Run mode. When exiting from STOP mode, the system clock, D3 domain bus matrix clocks and voltage scaling are reset, so they should be reconfigured.

Expected success behavior

Error behaviors

  • On failure, an error message is printed to the serial port.
  • Assumptions if any

    None

    Known limitations

    None

    Notes

    1. tx_low_power_enter() service enters low power mode. For keeping track of time while in low power mode, there are two possibilities:

      1.1. A ThreadX timer is active: Function tx_timer_get_next returns TX_TRUE. Note that in this situation, a low power clock must be used in order to wake up the CPU for the next ThreadX timer expiration. Therefore an alternative clock must be programmed. Program the hardware timer source such that the next timer interrupt is equal to: tx_low_power_next_expiration tick_frequency. The tick_frequency is application-specific and typically set up in tx_low_level_initialize.

      1.2. There are no ThreadX timers active: Function tx_timer_get_next returns TX_FALSE. 1.2.1. The application may choose not to keep the ThreadX internal tick count updated (define TX_LOW_POWER_TICKLESS), therefore there is no need to set up a low power clock. 1.2.2. The application still needs to keep the ThreadX tick up-to-date. In this case a low power clock needs to be set up.

    2. Under [AzureRTOS Application/ThreadX App Init] in STM32CubeMX, thread entry function name, thread name, priority and stack size, semaphore name and semaphore init count are defined.

    3. Entering low-power mode through WFI will be executed only if no interrupt is pending.

    4. The ‘debug in stop mode’ feature should be disabled using the HAL_DBGMCU_DisableDBGStopMode() API, otherwise, it will generate interrupts that cause the wake-up of the system immediately after entering the STOP mode.

    5. The user push-button interrupt priority must be set to the highest possible value, otherwise, after Exit STOP mode the processor will not execute the interrupt handler.

    6. To measure the current consumption remove JP4 jumper and connect an amperemeter to JP4 to measure IDD current.

    ThreadX usage hints

    Keywords

    RTOS, ThreadX, Threading, Semaphore, LowPower

    Hardware and Software environment

    How to use it ?

    In order to make the program work, you must do the following :