Interrupt 101


Closed Thread
Results 1 to 17 of 17

Thread: Interrupt 101

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Interrupt 101

    That's a good setup !
    How about switch de-bounce (make sure its a good press)

    I use;

    if sw not_pressed then out
    pause 10 ' or 20 or 50 ms
    if sw not_pressed then out
    good sw pressed stuff here

    don

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Interrupt 101

    You often don't need a debounce if you read a switch in software. Hardware is so fast that it can see one push as a bunch of pushes, but software is generally a lot slower and you can use that to your advantage. In the example I gave above, the bit gets set as soon as the first contact is made. If the main loop reads the bit at that time, and then does something that takes 50 mSec, you can clear ButtonFlag at the end of that routine (rather than at the top). The switch will certainly have quit bouncing by then, so the bit won't get re-set by the bounce. This saves 50mSec of waiting.
    If things really get "hairy", I do the debounce in ASM. I count the loops that the switch has been down (or up) and only generate a flag when that number of loops has been executed.

    My programming style uses PAUSE sparingly, if at all. That is the only way you can get real performance out of a PIC and PBP.
    Charles Linquist

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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