Can button be set to cause interrupt, and then it's functions changed?


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default Can button be set to cause interrupt, and then it's functions changed?

    Hello. The title looks a bit rubbish, but I don't know how to explain what I need.

    I need the following.

    CPU is sleeping, it has button connected. When user press button, cpu wakes up for defined amount of time (say, 60 seconds) and while cpu awake, this button no longer causes interrupt, but is used for other purposes, such as mode selection and so on. After 60 seconds passed, cpu enters sleep mode again.

    Is this doable using PBP ?

  2. #2
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Can button be set to cause interrupt, and then it's functions changed?

    Hey Curious One...

    Yes, I think what you want is very do-able.

    Just have your code disable the INT on that pin after the PIC wakes up.
    Then have your code watch that pin for change to select a given mode.
    When your 60 second timer (however you choose to implement the timer or some code in the loop you are running after the PIC is interrupted to increment a counter to keep track of time)
    Then re-enable the INT before putting the PIC back to sleep.

    I'm not the worlds best programmer by any stretch so my explanation above is very rough.

    The real trick is to figure out how to direct your PIC (write the code instructions) to do just what you want it to do. But then that is the challenge of any code :-)

    I hope this gives you some ideas.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  3. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Can button be set to cause interrupt, and then it's functions changed?

    Yep Most of it will work the way you want it to on it’s own.
    Especially since portb.o interrupt should cause wake up from sleep AND jump to the ISR where you can disable it.

  4. #4
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Can button be set to cause interrupt, and then it's functions changed?

    Can built-in timer used to count the time while circuit is on?

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Can button be set to cause interrupt, and then it's functions changed?

    That’s what DT’s Elapsed Timer does, yes, but if you want to use the portb.0 interrupt for a button as well,
    there is a separate DT package. I forget the name of that, but someone will chime in. It allows multiple interrupt sources.

Similar Threads

  1. String types and functions AND Functions with arguments
    By PickyBiker in forum PBP Wish List
    Replies: 3
    Last Post: - 1st January 2015, 09:00
  2. Help in trying to set pins functions
    By MinesCoffee in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th December 2012, 18:03
  3. Replies: 5
    Last Post: - 26th February 2011, 05:51
  4. multi functions button press
    By malwww in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th May 2009, 00:12
  5. How to set interrupt for Timer 0
    By chai98a in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 18th November 2006, 00:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts