Sleep with button

General discussion on mikroC.
Post Reply
Author
Message
jamz87
Posts: 1
Joined: 13 Oct 2010 02:21

Sleep with button

#1 Post by jamz87 » 13 Oct 2010 02:42

Hi,

I'm trying to wake my PIC16F690 via a button push. I've gotten the button routine to work with sleeping the PIC, I'm just not quite sure how to go about waking it up. Would using timer1 be the best route? Can anyone show me some sample code to get me started? Here's a snippet of my button code:

Code: Select all

while(1)                              // Loop forever
    {
    //Button interrupt code

   if(Button(&PORTC, 5, 1, 1))  // introduce debounce, RC5 100ms active high
    {
     btnpsh = 1;     //Button is pressed down
    }
    if(btnpsh && Button(&PORTC, 5, 1, 0))    // If button was pressed and is now unpressed
        {
           Lcd_Cmd(_LCD_CLEAR);                  // Clear display
           Lcd_Cmd(_LCD_CURSOR_OFF);             // Cursor off
           asm SLEEP;
        }
    //End button interrupt code
Thanks for the help in advance,
Mike

Post Reply

Return to “mikroC General”