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.

Sleep mode configuration!

Other Parts Discussed in Thread: TM4C1230H6PM, LMFLASHPROGRAMMER

Hi!

we are new to Tiva TM4C123G, can any one help us or guide to configure the CPU for sleep mode?. 

we already knew that this controller have many option to save the power better than sleep mode. But we want to integrate this sleep mode in our project.

So its a kind request to all, pls. help us!

Thanks in advance

Pramod

  • Hi,

       There is some mention about sleep mode at Tiva TM4C123G datasheet. You, can also check example programs for sleep mode here or elsewhere in the internet.

    -kel

  • Hello Kel,

    If you know the link, pls. forward to us. your little effort can save our task.

    thanks

  • Hello Pramod,

    The use of Sleep mode requires the following

    1. Configuration of which peripherals need to be clocked in Sleep mode: Use SysCtlPeripheralSleepEnable or SysCtlPeripheralSleepDisable API to decide that

    2. Configuration to auto load Sleep Mode Clocking of peripheral using SysCtlPeripheralClockGating(true)

    3. Configuration of SRAM and/or Flash to be in Low Power State SysCtlSleepPowerSet API Call

    4. Finally calling Sleep Function using SysCtlSleep()

    Regards

    Amit

  • Thanks Amit,

    Could you pls tell us the config parameter of SysCtlSleepPowerSet() function?

    Because we refer SysCtl.h file but could not find the same.

    Pramod

  • Dear Amit,


    We found some references from the same forum, pls find the below code sequence of sleep mode configuration

    uC_Sleep_mode()

    {   

          SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0);             //Enable uart0 peripheral in sleep mode
          ROM_SysCtlPeripheralClockGating(true);
          SysCtlSleepPowerSet(SYSCTL_FLASH_LOW_POWER | SYSCTL_SRAM_LOW_POWER);
          ROM_SysCtlSleep();

    }

    But it's didn't work for us. kindly suggest the changes

    Pramod

  • Hello Pramod,

    The defines are there in TIVAWare 2.1.0 release. Also when you it didn't work, could you elaborate on what did not work?

    Please note that when in Sleep or Deep Sleep, the CPU will be woken up by an interrupt and/or reset only

    Regards

    Amit

  • pramod patil said:
    If you know the link, pls. forward to us. your little effort can save our task.

    It's happened - finally - be still my (bit aged) heart!

    (Likely) homework-seeking poster has condemned responder for, "Too little effort!"  (trumpet fanfare, maestro...)  Surely teaches friend Kel to be bit selective in his quick/dirty responses...

    And - poster adds to this injury by later graduating to famed, always supremely helpful, "Didn't Work for us!" 

  • Hello Amit,

    Thanks for the valued suggestion, If controller in sleep mode, it should not continuously throws the messages on Hyper Terminal through UART0 interface.

    Because we enable the sleep peripheral for UART0(SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0)).

    Or is there any way to cross verify the sleep mode?

    pramod

  • Hello Cb1,

    We are not getting you from  your post, could you explain once? its helpful to us to get the supports from others.

    pramod

  • Hello Pramod,,

    If you have enabled the peripheral in Sleep Mode and device has gone into sleep mode then the peripheral will remain active for any data transaction in sleep mode.

    To make sure that the device is in Sleep Mode you can use the register SYSCTL.LDOSPCTL by writing the value 0x80000012 to it. Do make sure that you run the System Clock at 20MHz. When the device does go into Sleep Mode the VDDC pin will drop to 0.9V and will come back to 1.2V on an Interrupt/Reset.

    It is also important to note that the CCS Debugger needs to be disconnected so that the register takes effect.

    Regards

    Amit

  • Hello Amit,

    Is there any way to configure controller for sleep mode? because in errata they mentioned "ROM_SysCtlSleep()" not working. Instead of that use assembly in coding. but for us its very difficult to work out in asm code in keil.

    Pramod

  • Hello Pramod,

    You can use the Flash version by calling SysCtlSleep()

    Regards

    Amit

  • No Amit,

    Its also not working!

    pls. find the below code n suggest if there any changes are required

     unsigned char uC_Controller_Sleep()        
           {

           SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0);             //Enable uart0 peripheral in sleep mode
            ROM_SysCtlPeripheralClockGating(true);
            SysCtlSleepPowerSet(SYSCTL_FLASH_LOW_POWER | SYSCTL_SRAM_LOW_POWER);
            SysCtlSleep();
            return(1);
          }

  • Hello Pramod,

    Yes, this is correct. What is not working, can you be more precise? Also do remember that Debugger connected will not allow Sleep Transition even though it will enter the function SysCtlSleep.

    Regards

    Amit

  • Hello Amit,

    After configuring and enabling UART0 in Sleep mode, we are not supposed to receive any character or string from UART0(configure without interrupt). But we are continuously received the same.

    Our understanding is, without any interrupt or calling function of controller should not wake up to controller? but its not happened in our case.

    pls. suggest!

    pramod

  • Hello pramod

    A CCS project file at this point would be useful to see what is happening if I can get it to work on my LaunchPad

    Regards

    Amit

  • No Amitt,

    Dev. Platform is keil, if we got any solution for this issue surely we can update the same on this forum.

    BTW, thanks for your kind support to educate us on Tiva platform.

    Pramod

  • Hello Pramod,

    I will send across a simple C file tested with Sleep Mode. I would need the following information

    1. TIVA Part you are using

    2. SYSCTL.DID0 register value

    Regards

    Amit

  • Dear Amit,


    1. Tiva Part No. TM4C1230H6PMI/ package : LQFP64

    2. SYSCTL DIDO Reg. value: 0x18050101

  • Hello Amit,

    1. Tiva Part No. TM4C1230H6PMI

    2. SYSCTL.DID0 Reg. Value:  0x18050101

    Regards,

    Pramod

  • Hello Pramod,

    I have attached a CCS Project for the device (The device is TM4C1230H6PM and not TM4C1230H6PMI)

    I have tested it on a LaunchPad

    1. When you flash the program the VDDC Pin will show 0.9V after some time

    2. If you press PF4 Switch on the LaunchPad it will show 1.2V and on releasing the switch it will go back to 0.9V

    http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/908/3527.TM4C123_5F00_Sleep.7z

    Regards

    Amit

  • Dear Amit,

    Thanks, code is working on keil IDE. now controller goes into sleep mode.

    But we did a basic silly mistake during the code flash, unfortunately I comment out isr routine and its peripheral. :)

    Now we face another problem to wake up the controller from sleep. If we try to load the code it shows a error message "can not load flash programming algorithm".

    But in debug, we can able to view the code and even step out the code. Is there any way to wake up  controller? from sleep mode.

    Regards,

    Pramod

  • Hello Pramod,

    To wake up from Sleep you would need an Interrupt from a peripheral. To ensure that the peripheral can generate an interrupt in sleep mode, you need to make sure that the SysCtlPeripheralSleepEnable for the Peripheral is set.

    In case you run into the issue as mentioned

    1. Remove the 0.9V voltage scaling as the maximum frequency for 0.9V is 20MHz

    2. Last resort is to do a unlock sequence which will erase the flash. For this you can use the LMFlashProgrammer utiltiy

    Regards

    Amit

  • Dear Amit,

    We unlock the controller and properly configured for sleep mode, but still its showing 1.22V at VDDC pin.

    It means controller is not in sleep mode? pls. suggest?

    Regards,

    Pramod

  • Hello Pramod,

    Let me remind: One of my earlier post has mentioned that with the debugger connected the LDO "will not scale". So can you remove the debugger and power cycle the board.

    If this is not the case with the code I sent, then please post the C file so that I can check

    Regards

    Amit

  • Dear Amit,

    We checked the code without debugger, but there is no change is observed on controller VDDC voltage.

    pls. go through the following code

    //*****************************************************************************
    // power down.c - program for configuring and to save the poer of system while executing in idle mode
    //
    //*****************************************************************************

    #include <stdint.h>
    #include <string.h>
    #include <stdbool.h>
    #include <stdlib.h>
    #include "./inc/hw_ints.h"
    #include "./inc/hw_memmap.h"
    #include "./inc/hw_types.h"
    #include "./inc/hw_uart.h"
    #include "./driverlib/adc.h"
    #include "./driverlib/rom.h"
    #include "./driverlib/rom_map.h"
    #include "./driverlib/sysctl.h"
    #include "./driverlib/pin_map.h"
    #include "./driverlib/uart.h"
    #include "./utils/uartstdio.h"
    #include "./driverlib/gpio.h"
    #include "utils/ustdlib.h"
    #include "driverlib/hibernate.h"

    #include "BMS.h"
    #include "POWER DOWN.h"
    #include "./driverlib/cpu.h"

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

     unsigned char uC_Controller_Sleep()        
    {

                    ROM_SysCtlPeripheralClockGating(true);    
        
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOA);    
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOB);    
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOC);    
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOE);    
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);    
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOG);    
        
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0);                
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART1);                                
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART2);                                                
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART3);                                                                
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART4);                                                                                
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART5);                
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART6);                                
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART7);    
                    
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER0);    
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER1);    
                    
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_I2C1);                
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_I2C2);                                
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_I2C3);
        
                    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_WTIMER5);
                    SysCtlLDOSleepSet(SYSCTL_LDO_0_90V);

                    SysCtlSleepPowerSet(SYSCTL_FLASH_LOW_POWER|SYSCTL_SRAM_LOW_POWER);
        
                    SysCtlSleep();                                                                                                           
                    return(1);
    }

    void power_down()
    {        
              ROM_IntMasterDisable();                    // Disable all interuupts
        
              UARTprintf("System in Sleep Mode\n");                
              ROM_SysCtlDelay(1000000);                               // delay for demonstration use only
                                
              uC_Controller_Sleep();                                         // Controller in sleep mode      
    }

  • Hello Pramod,

    1. The code looks correct and only thing at this point could be that one of the peripherals is giving interrupts causing the device to wake. You may have to check which peripheral may be generating an interrupt. Another way to do the same would be to comment out the SysCtlPeripheralSleepEnable one-by-one to reach to the peripheral causing it...

    2. The code I sent allowed the device to go into deep sleep and voltage to scale to 0.9V in your system?

    Regards

    Amit

  • No Amit,

    Even if we comment out all SysCtlPeripheralSleepEnable() functions, the result is same.

    Even we can not sure, if this controller really supports to sleep mode?. I am totally fade up with this mode.

    Is there any hope to achieve Sleep mode task?

    Pramod

  • Hello Pramod,

    I can try using the code snippet you sent on my setup. What is strange is that earlier the same code was sowing 0.9V and not it does not anymore...

    Regards

    Amit

  • Dear Amit,

    It's happened because of shaking DMM probe while measuring the voltage of VDDC pin on DMM for sleep mode. And we thought that it has been gone into sleep mode. For this test we will use your given code,but in actual we never seen controller put himself in sleep mode after calling sleep mode instruction.

    Regards,

    Pramod

  • Hello Pramod,

    It seems that voltage scaling is not allowed for the Sleep Mode. Please check the LDOSPCAL register in System Control. if it has 0x18 then it would not allow the voltage scaling.

    To make sure it is in sleep mode, make a GPIO high before executing SysCtlSleep and then make it low after exiting due to an interrupt.

    If the GPIO remains 1 till an interrupt is not seen, then you are in sleep mode.

    Regards

    Amit

  • Hello Amit,

    Thanks, finally problem would get solved! "SysTickHandler" function continuously added the ticks into the controller.

    Because of this only we face this problem.

    pls find the attached  sample source code for the ref of sleep mode configuration.

    Regards,

    Pramod

    0284.TM4C123_Sleep.rar

  • Hi Amit,

    I am also trying to implement sleep mode but so far I am not getting that is my sleep mode is working or not?

    Please find below code:

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/timer.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    int
    main(void)
    {
    FPULazyStackingEnable();
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
    SYSCTL_XTAL_16MHZ);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_1);
    GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_PIN_1);
    SysCtlDelay(16000000/3);
    SysCtlSleep();

    while(1)
    {
    }
    }

    In above code I am able to switch ON my LED but after that it stays ON continuously. If in my code is activating sleep mode my LED should be switched OFF but it is continuously switched ON. 

    So I tried  below code to verify the same:

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/timer.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    int
    main(void)
    {
    FPULazyStackingEnable();
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
    SYSCTL_XTAL_16MHZ);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_1);
    GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_PIN_1);
    SysCtlDelay(16000000/3);
    SysCtlSleep();

    GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,0);

    while(1)
    {
    }
    }

    But still same result. Can you guide me up with the same to get into sleep mode?

    Thanks.

  • Hello Mitesh

    What is the source of exit from Sleep Mode. Once the Sleep Mode is entered only an interrupt event can make the CPU exit the Sleep Mode. Also for the Sleep Mode setting to work, the DAP must be cleared of debug enable, which can be done by Power Cycling the board after the debugger has been disconnected from the IDE.

    Regards
    Amit
  • Hello Amit,

    Thanks for instant reply.
    My question is while getting into sleep mode LED's Should be turned OFF which is not happening..
    Is it correct?

    Also I wrote whole code so that code should come out of sleep mode but it is also not working.
    Please find code below:


    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.c"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.c"
    #include "driverlib/gpio.h"


    /*
    These defines help if you want to change the LED pin or the Button pin.
    Remember if you change to a diferent GPIO you need to enable the system
    clock on it
    */
    #define LED_PERIPH SYSCTL_PERIPH_GPIOF
    #define LED_BASE GPIO_PORTF_BASE
    #define RED_LED GPIO_PIN_1

    #define Button_PERIPH SYSCTL_PERIPH_GPIOF
    #define ButtonBase GPIO_PORTF_BASE
    #define Button GPIO_PIN_4
    #define ButtonInt GPIO_INT_PIN_4

    volatile uint8_t value=0;
    int state=0;
    uint8_t count=0;
    uint32_t status=0;

    void IntHandler()
    {
    // status = GPIOIntStatus(ButtonBase,true);
    GPIOIntClear(ButtonBase,GPIO_INT_PIN_4);
    value= GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4);
    // SysCtlDelay(16000000/100);
    if( value==0)
    {
    state += 1;
    }
    if(state%2 == 0)
    {
    SysCtlSleep();
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1,GPIO_PIN_1);
    }
    else
    {
    GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1,GPIO_PIN_1);
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1,0);
    }
    }


    int main(void)
    {

    SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);
    GPIOPadConfigSet(GPIO_PORTF_BASE ,GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
    GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_FALLING_EDGE);
    GPIOIntRegister(GPIO_PORTF_BASE,IntHandler);
    GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_4);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_1);

    // GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1,GPIO_PIN_1);
    SysCtlPeripheralClockGating(true);
    SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralClockGating(true);
    SysCtlLDOSleepSet(SYSCTL_LDO_1_15V);
    SysCtlSleepPowerSet(SYSCTL_SRAM_STANDBY);
    while(1)
    {

    }
    }


    I have also got one question what is DAP?
  • Hello Amit,

    I have just wrote the code to get into sleep mode. According to me when sleep mode is activated LED should be switched OFF. But it is not switching OFF. Is it correct with what is getting implemented?

    My complete code is as follows:


    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.c"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.c"
    #include "driverlib/gpio.h"


    /*
    These defines help if you want to change the LED pin or the Button pin.
    Remember if you change to a diferent GPIO you need to enable the system
    clock on it
    */
    #define LED_PERIPH SYSCTL_PERIPH_GPIOF
    #define LED_BASE GPIO_PORTF_BASE
    #define RED_LED GPIO_PIN_1

    #define Button_PERIPH SYSCTL_PERIPH_GPIOF
    #define ButtonBase GPIO_PORTF_BASE
    #define Button GPIO_PIN_4
    #define ButtonInt GPIO_INT_PIN_4

    volatile uint8_t value=0;
    int state=0;
    uint8_t count=0;
    uint32_t status=0;

    void IntHandler()
    {
    GPIOIntClear(ButtonBase,GPIO_INT_PIN_4);
    value= GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4);
    if( value==0)
    {
    state += 1;
    }
    if(state%2 == 0)
    {
    SysCtlSleep();
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1,GPIO_PIN_1);
    }
    else
    {
    GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1,GPIO_PIN_1);
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1,0);
    }
    }


    int main(void)
    {

    SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);
    GPIOPadConfigSet(GPIO_PORTF_BASE ,GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
    GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_FALLING_EDGE);
    GPIOIntRegister(GPIO_PORTF_BASE,IntHandler);
    GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_4);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);


    // GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1,GPIO_PIN_1);
    SysCtlPeripheralClockGating(true);
    SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralClockGating(true);
    SysCtlLDOSleepSet(SYSCTL_LDO_1_15V);
    SysCtlSleepPowerSet(SYSCTL_SRAM_STANDBY);
    while(1)
    {

    }
    }


    In above code also I am unable to increase count of my variable "state", it means I am unable to wake my controller. Please guide me if any thing is wrong.

    Thanks,
    Mitesh
  • Hello Mitesh,

    Why an interrupt handler need to have a sleep condition. Why can't a flag be updated that causes the CPU to go to sleep in the main code.

    Once the CPU is in sleep, there shall be no further code execution.

    Regards
    Amit
  • Hi Amit,

    I have just tested with the same modification as you suggested. But still no positive result.
    I need to know is my code going properly in sleep mode? As LED is switched ON in sleep mode too so I have a doubt on the same.

    Please find updated code below:


    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.c"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.c"
    #include "driverlib/gpio.h"

    volatile int value=0;
    int state=0;
    int count=0;
    int status=0;

    void IntHandler()
    {
    // status = GPIOIntStatus(ButtonBase,true);
    GPIOIntClear(GPIO_PORTF_BASE,GPIO_INT_PIN_4);
    value= GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4);
    // SysCtlDelay(16000000/100);
    if( value==0)
    {
    state += 1;
    }
    }


    int main(void)
    {

    SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);
    GPIOPadConfigSet(GPIO_PORTF_BASE ,GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
    GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_FALLING_EDGE);
    GPIOIntRegister(GPIO_PORTF_BASE,IntHandler);
    GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_4);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_1|GPIO_PIN_2);

    // GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1,GPIO_PIN_1);
    // SysCtlPeripheralClockGating(true);
    SysCtlPeripheralClockGating(true);
    SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlLDOSleepSet(SYSCTL_LDO_1_15V);
    SysCtlSleepPowerSet(SYSCTL_SRAM_STANDBY);
    while(1)
    {

    if(state%2 == 0)
    {
    GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1,GPIO_PIN_1);
    }
    if(state%2 == 1)
    {
    SysCtlSleep();
    }
    }
    }

    Let me know if I am still falling short of anything to be initialized.

    Thanks,
    Mitesh
  • Hello Mitesh,

    If you use a debugger, then does the code execute to SysCtlSleep? If, yes then on the next power cycle when the debugger is disconnected, the same conditions will cause the device to go to Sleep.

    Regards
    Amit
  • Hi Amit,

    I am not using any separate debugger, I am just debugging using CCS.I have found 2 points it would be great if you can help me out here.

    1) I used break point I can see my code is getting into function SysCtlSleep() and my device goes into sleep mode.

    2) If I use PortD as output port after one cycle of loops I get stuck in FaultISR while loop. I don't know how and why? Is my code correct or is there any issue?

    Kindly let me know if you find any bug?

    Thanks,

    Mitesh

  • Hi Amit,

    It looks like my device has not came out of sleep mode. If I use the function SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOD); , it works fine else it directs to faultISR Routine.

    I also havve an query, If my device goes into sleep mode its VDDC voltage still remains 1.2V. Is there any point from which we can know that our device is in sleep mode?
  • Hello Mitesh,

    You may use the LDOSPCTL to lower the voltage to see the device going into Sleep Mode, or use a current sense on the path to see the drop in current consumption.

    Regards
    Amit
  • Hi Amit,

    Thanks for your support. It did worked.

  • Hello Mitesh,

    If you can upload the C file to the post, it would be a good forum resource,

    Regards
    Amit
  • Hi Amit,

    You can share below code. that works fine for me.

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.c"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.c"
    #include "driverlib/gpio.h"

    volatile int value=0;
    int state=0;
    int count=0;
    int status=0;

    void IntHandler()
    {
    // status = GPIOIntStatus(ButtonBase,true);
    GPIOIntClear(GPIO_PORTF_BASE,GPIO_INT_PIN_4);
    value= GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4);
    // SysCtlDelay(16000000/100);
    if( value==0)
    {
    state += 1;
    }
    }


    int main(void)
    {

    SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);
    GPIOPadConfigSet(GPIO_PORTF_BASE ,GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
    GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_FALLING_EDGE);
    GPIOIntRegister(GPIO_PORTF_BASE,IntHandler);
    GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_4);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_1|GPIO_PIN_2);

    SysCtlPeripheralClockGating(true);
    SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlLDOSleepSet(SYSCTL_LDO_0_90V);
    SysCtlSleepPowerSet(SYSCTL_SRAM_STANDBY);
    while(1)
    {

    if(state%2 == 0)
    {
    GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1,GPIO_PIN_1);
    }
    if(state%2 == 1)
    {
    SysCtlSleep();
    }
    }
    }

  • Hello Amit,

    Can you please respond to this post?

    e2e.ti.com/.../1784740


    Thanks,
    Mitesh