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.

How to configure UART as a wake up source in MCU Tiva TM1294NCPDT?

Other Parts Discussed in Thread: TM4C1294NCPDT, EK-TM4C1294XL

I am using MCU Tiva TM4C1294NCPDT. I would like to know how to put MCU in sleep mode and set up UART as a  wake up source. Thankyou

  • Hello Anjana,

    The example

    D:\ti\TivaWare_C_Series-2.1.1.71\examples\boards\ek-tm4c1294xl\sleep_modes

    would show how to configure the device for sleep mode. To enable UART for a wakeup, you would need to ensure that the Sleep Mode clocking for UART is enabled and that the RX interrupt is set, so that when a new character is received the UART peripheral can wakeup the device.

    Regards
    Amit
  • Hi Amit,

     

    I saw the code in github. It isnt very clear to me. Could you give me an example of getting into sleep mode by giving UART as a wake up source

  • Hello Anjana

    I would also give the same code!!! You may have to explain what is not clear to you?

    Regards
    Amit
  • Hi Amit,

    What I am trying to do is toggle the LED's in normal mode. So that when I enter sleep mode, they stop toggling. The wake up source is UART7.

    This is the snippet of the code:-

    void main
    {

    /*Enable UART7 in sleep mode*/
    SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART7);

    /*To set wake up source*/
    benable = IntMasterEnable();/*Enable interrupts to the processor*/
    if(0u == benable)
    {
    System_printf("interrupts to the processor not enabled\r\n");
    System_flush();
    }
    IntRegister(INT_UART7, UART7Handler); /*Registers a function to be called when an interrupt ocurs*/
    IntPrioritySet(INT_UART7, 0); /*Set the USB 0 interrupt priority to the highest priority*/
    IntEnable(INT_UART7); /* Enables UART6 as an interrupt

    Set_Battery_Mode();
    }



    void UART7Handler(void)
    {
    Set_Normal_Mode();

    }


    void Set_Battery_Mode(void)
    {

    SysCtlSleep();

    }

    Is this correct?
  • Hello Anjana

    Where have you configured the UART7. I do not see the enabling of the clocks to UART7, its initialization and setting the Interrupt Mask bit for Receive.

    The UART7 clock enable and initialization would be the same as that for UART0 as in most of the example codes in TivaWare.

    Regards
    Amit
  • Hi Amit,

    I tried what you said but in vain. Let me paste my code again.

    /******************************.FUNCTION_HEADER.******************************

    .Purpose        : Sets System power mode to battery mode

    .Returns        : None

    .Note           : None

    ******************************************************************************/

    uint8_t Set_Battery_Mode(

    void)

    {

    uint8_t wifi_ret;

    bool benable;

    /*Enable UART7 in sleep mode*/

    SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART7);

    UARTClockSourceSet(UART7_BASE, UART_CLOCK_PIOSC);

    /*Sleep mode clocking for UART is enabled */

    /*To set wake up source*/

    benable = IntMasterEnable();

    /*Enable interrupts to the processor*/

    if(0u == benable)

    {

    System_printf(

    "interrupts to the processor not enabled\r\n");

    System_flush();

    }

    IntRegister(INT_UART7, UART7Handler);

    /*Registers a function to be called when an interrupt ocurs*/


    IntPrioritySet(INT_UART7, 0);

    /*Set the UART 7 interrupt priority to the highest priority*/

    IntEnable(INT_UART7);

    /* Enables UART7 as an interrupt in the interrupt controller*/

    UARTIntEnable(UART7_BASE, UART_INT_RX);

    /* Rx has been set up as an interrupt source*/

    wifi_ret = WiFi_OFF();

    if(0 == wifi_ret)

    {

            System_printf(

    "\nWiFi OFF Success...\r\n");

    System_flush();

    }

    else

    {

    System_printf(

    "\nWiFi OFF failed....\r\n");

    System_flush();

    }

    SysCtlSleep();

    gu8_current_mode = BATTERY_MODE;

    return gu8_current_mode;

    }

    /******************************.FUNCTION_HEADER.******************************

    .Purpose        : When an interrupt occurs, the handler runs

    .Returns        : Returns system status

    .Note           : None

    ******************************************************************************/

    void

    UART7Handler(void)

    {

    //Set_Normal_Mode();


    }

    Kindly help.

  • Hello Anjana,

    Please make sure that the debugger is disconnected as the device cannot sleep or deep sleep with the debugger connected.

    Regards
    Amit
  • Hi Amit,

    I tried without the debugger connected. I still did not find any reduction in current.

    Regards,

    Anjana

  • Hello Anjana,

    Simplify. First use the existing project (non TI-RTOS) to set up your system and make current measurements to see if the currents are in expected ball park.

    Regards
    Amit
  • Hi Amit,

    I created a setup comprising of 2 UARTs, 6 and  7. Data is read from UART7 and through UART6, data is written. UART7 is the wakeup source.

    After executing the below code, UART7 becomes non - functional, which means UART 7 peripeheral goes into sleep, where as UART 7 should be the wake up source. How do I put the entire system into sleep with only UART7 as the wake up source?

     

    /*Enable UART7 in sleep mode*/

    SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART7);

    /*Sleep mode clocking for UART is enabled */

    UARTClockSourceSet(UART7_BASE, UART_CLOCK_PIOSC);

    /*To set wake up source*/

    benable = IntMasterEnable();

    /*Enable interrupts to the processor*/

    if(0u == benable)

    {

    System_printf(

    "interrupts to the processor not enabled\r\n");

    System_flush();

    }

    /*Registers a function to be called when an interrupt ocurs*/

    IntRegister(INT_UART7, UART7Handler);

     

    /*Set the UART 7 interrupt priority to the highest priority*/

    IntPrioritySet(INT_UART7, 0);

    /* Enables UART7 as an interrupt in the interrupt controller*/

    IntEnable(INT_UART7);

    /* Rx has been set up as an interrupt source*/

    UARTIntEnable(UART7_BASE, UART_INT_RX);

     /*System goes to sleep mode*/

    SysCtlSleep();

    Regards,

    Anjana

  • Hi Amit,

    I havent response from you or anyone yet. It is a bit important as well as urgent.

    Thankyou.

    Regards,

    Anjana

  • Hello Anjana,

    The test setup is not valid. If UART6 and UART7 are in loopback mode, then the system cannot be sleep for the simple logical reason that CPU will have to process the transmit path and it has to be active and not in Sleep. Thus system cannot be in sleep mode.

    Regards
    Amit
  • Hi Amit,

    CPU transmits only in the normal mode, which is through UART6. In sleep mode, it is supposed to wake up on reception, which is through UART7.

    I have sent you a snippet of the code, where I am putting system in sleep mode. Can you guide me with that code?Or give any suggestions on the same.

     

    Thankyou,

     

    Regards,

    Anjana

     

     

  • Hello Anjana

    Attached is a code for UART7 Sleep Mode entry and exit. I have used a EK-TM4C1294XL and removed the shunt jumper JP5 and JP4 and wired the ICDI TX and RX to UART7 RX and TX.

    On every key press the LED will glow and go off alternatively. Between 2 key press the device will remain in Sleep Mode.

    uart7_sleep.zip

    Regards

    Amit