This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Power Management for UART Drivers

Other Parts Discussed in Thread: SYSBIOS

Hello:

I am try to learning Power Management for UART Drivers IN RTOS ,  does any sample code can refer ?

Thank you.

  • Tzuyu,

    Which device are you using, and which version of TI-RTOS?

    Thanks,
    Scott

  • Dear Scott:

  • Tzuyu,

    OK, thanks.  

    There is a UART example in that release (UART Echo), which has power management enabled and supported in the UART driver.  But because of how this example is written, it won’t automatically transition to a deep power saving state.  This is because the UART is always opened in receive mode, which means the UART driver is always asserting a constraint to tell the power manager to not transition the device to the Standby state (so that it will be able to receive UART data).

    Tomorrow I’ll see if there is another example I can send to you, or maybe provide some notes on how to modify this example so you can see the power management transitions…

    Regards,
    Scott

  • Tzuyu,

    Here is a simple modification to the UART Echo example, so that you can see the device transition in/out of the Standby state.

    In echoFxn() in uartecho.c, replace this code:

        /* Loop forever echoing */
        while (1) {
            UART_read(uart, &input, 1);
            UART_write(uart, &input, 1);
        }

    With this:

        while (1) {
            UART_read(uart, &input, 1);
            UART_control(uart, UART_CMD_RXDISABLE, NULL);
            Task_sleep(10000000/Clock_tickPeriod);
            UART_control(uart, UART_CMD_RXENABLE, NULL);
            UART_write(uart, &input, 1);
        }

    You’ll also need to include Clock.h to resolve Clock_tickPeriod:

    #include <ti/sysbios/knl/Clock.h>

    With these changes, the CPU will read one character, sleep for 10 seconds, echo the character to the terminal, read one character, …   

    The “UART_control(uart, UART_CMD_RXDISABLE, NULL)” will disable RX functionality of the UART, which will allow the UART driver to release its constraint prohibiting Standby.  And then after wake from Standby, “UART_control(uart, UART_CMD_RXENABLE, NULL)” will reenable RX for the UART, so that a new character can be read from the terminal.  The UART_write() will echo the character typed just before Standby, and then the loop continues.

    Note that after you load the program you’ll need to close the debugger and reset the board, to allow the device to actually transition to Standby after each character.  This is because an active debug session will force portions of the device to stay awake, and the current won’t drop all the way to the Standby level.

    This is a bit of an odd example, but hopefully it illustrates the concept of the driver using power constraints to control the depth of sleep chosen by the power policy.   

    For a UART in write-only mode, the RX functionality could be disabled once after UART_open().  Then when UART_write() is called, the UART driver automatically raises the constraint, the data is written, and then the UART driver automatically releases the constraint.  So the application wouldn’t need to do the UART_control() calls as shown above.

    I hope this all makes sense.  

    If you haven’t seen it, there is a Power Management User’s Guide (at .\docs\Power_Management.pdf) that describes the power management concepts.

    Regards,
    Scott

  • Dear Scott:

    I do really refer Power Management User’s Guide 

    3276.Power_Management_CC26xx.pdf

    but Example : UART Drive seems can't working.

    First , Power_setDependency(hwAttrs->powerMngrId) , I get error ...

  • Tzuyu,

    The doc you attached is from an old release of TI-RTOS.  In the screenshot of the CCS General properties page you posted earlier, I can see that you have an older release that was named “TI-RTOS for SimpleLink Wireless MCUs”, and this doc must have come from that.  In the “TI-RTOS for CC13XX and CC26XX, 2.20.0.06” installation also shown in the properties page, you will find and updated Power Management User’s Guide, dated June 2016 at this path (assuming you installed in “C:\ti”):  C:\ti\tirtos_cc13xx_cc26xx_2_20_00_06\docs\Power_Management.pdf)  You should refer to this one as there have been various updates over the last 2 years.  

    That said…  it seems you are trying to build the code snippets shown in the document, in the driver writer’s chapter where there are snippets of the UART driver code used to explain the power management concepts.  .  Those snippets were extracted from the UART driver sources, and won’t build by themselves, but require additional UART driver source code not shown in the document.  You can find the full UART driver sources (that these were taken from) in your installation at this path: C:\ti\tirtos_cc13xx_cc26xx_2_20_00_06\products\tidrivers_cc13xx_cc26xx_2_20_00_08\packages\ti\drivers\uart\UARTCC26XX.c

    I hope this clarifies…

    Regards,
    Scott