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.

  • Resolved

CCS/TM4C123GH6PM: TM4C123GXL

Part Number: TM4C123GH6PM

Tool/software: Code Composer Studio

Hi,

so i have this code which from the times i executed it seems to do what i entended for it to do from the first place: ''entering Hibernate mode and then waking up with external push button''.

i'm suppose to make sure that my board did actualy enter hibernate mode and then woke up.

//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif


//*****************************************************************************
//
// Configure the UART and its pins.  This must be called before UARTprintf().
//
//*****************************************************************************
void
ConfigureUART(void)
{
    //
    // Enable the GPIO Peripheral used by the UART.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    //
    // Enable UART0
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    //
    // Configure GPIO Pins for UART mode.
    //
    ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
    ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Use the internal 16MHz oscillator as the UART clock source.
    //
    UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

    //
    // Initialize the UART for console I/O.
    //
    UARTStdioConfig(0, 115200, 16000000);
}

//*****************************************************************************
//
// The interrupt handler for the Buttons.
//
//*****************************************************************************

void BottonsHandler(void){
      if((GPIOIntStatus(GPIO_PORTF_BASE,true)& Buttoninit1))
      {
          GPIOIntClear(GPIO_PORTF_BASE,Buttoninit1);// Clear interrupt flag
          TimerEnable(TIMER0_BASE, TIMER_A);//Enables the timer
      }
      else if((GPIOIntStatus(GPIO_PORTF_BASE,true)& Buttoninit0))
            {
                GPIOIntClear(GPIO_PORTF_BASE,Buttoninit0);// Clear interrupt flag
                TimerDisable(TIMER0_BASE, TIMER_A);//Disables the timer
                SysCtlPeripheralDisable(SYSCTL_PERIPH_HIBERNATE);//Disables the Hibernation module
                HibernateGPIORetentionDisable();//Disable GPIO retention
                HibernateDisable();//Disables the Hibernation module for operation.

            }
}
void configureButtons(void){
//configureButton0
      GPIOPinTypeGPIOInput(ButtonBase, Button0);
      GPIOPadConfigSet(ButtonBase ,Button0,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);// Register our handler function for port F
      GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_0,GPIO_FALLING_EDGE);// Configure PF4 for falling edge trigger
      GPIOIntRegister(GPIO_PORTF_BASE,BottonsHandler); // Register our handler function for port F
      GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_0);// Enable interrupt for PF0
//configureButton1
      GPIOPinTypeGPIOInput(ButtonBase, Button1);
      GPIOPadConfigSet(ButtonBase ,Button1,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);// Register our handler function for port F
      GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_FALLING_EDGE);// Configure PF4 for falling edge trigger
      GPIOIntRegister(GPIO_PORTF_BASE,BottonsHandler);// Register our handler function for port F
      GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_4);// Enable interrupt for PF4

}

void
Timer0IntHandler(void)
{

   //
   // Clear the timer interrupt.
   //
   TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

   UARTprintf("Hibernate mode is on!\n");

   SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);// enable the hibernation module
   HibernateEnableExpClk(SysCtlClockGet());//defines the clock supplied to the hibernation module
   HibernateGPIORetentionEnable(); //Calling this function enables the GPIO pin state to be maintained during hibernation .
   SysCtlDelay(SysCtlClockGet()/10 );

   HibernateWakeSet(HIBERNATE_WAKE_PIN);//set the wake condition to the wake pin
   SysCtlDelay(SysCtlClockGet()/10 );
   GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3, 0);//turn off the green LED before the device goes to sleep.
   /*enable the device to wake on either the RTC or the WAKE
   pin. */
   //HibernateRTCSet(0);
   //HibernateRTCEnable();
  // HibernateRTCMatchSet(0,10);
   //HibernateWakeSet(HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC);

   /*function requests the Hibernation module to disable the external regulator, removing power from the
   processor and all peripherals.*/

   HibernateRequest();
}



//*****************************************************************************
//
// Print "Hello World!" to the UART on the evaluation board.
//
//*****************************************************************************
int
main(void)

{
    //volatile uint32_t ui32Loop;

    //
    // Enable lazy stacking for interrupt handlers.  This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    //ROM_FPULazyStackingEnable();

    //
    // Set the clocking to run directly from the crystal.
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
                       SYSCTL_OSC_MAIN);

    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    // Enable the GPIO pins for the LED (PF2 & PF3).
    //
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);

    //
    // Enable the peripherals used by this example.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);

    //
    // Enable processor interrupts.
    //
    ROM_IntMasterEnable();

    //
    // Configure the two 32-bit periodic timers.
    //
    ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
    ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ROM_SysCtlClockGet());

    //
    // Setup the interrupts for the timer timeouts.
    //
    ROM_IntEnable(INT_TIMER0A);
    ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    //
    // Registers an interrupt handler for the timer interrupt.
    //
    TimerIntRegister(TIMER0_BASE,TIMER_A,Timer0IntHandler);
    //
    // Initialize the UART.
    //
    ConfigureUART();
    //
    //Initialize the Buttons.
    //
    configureButtons();
    //
    // Hello!
    //
    UARTprintf("Hello, world!\n");
    SysCtlDelay(SysCtlClockGet());

    while(1)
    {
        UARTprintf("Run mode is on!\n");
        SysCtlDelay(SysCtlClockGet());
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3,GPIO_PIN_3 );
        SysCtlDelay(SysCtlClockGet()/10 );
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3,0);
        SysCtlDelay(SysCtlClockGet()/10 );

    }
}

i don't know how to proceed...any help !!    

regards

amine

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.