Switch Polling vs Interrupts


Closed Thread
Results 1 to 2 of 2
  1. #1
    eric blair's Avatar
    eric blair Guest

    Question Switch Polling vs Interrupts

    Using 16F876-04/SP

    Hi
    I am a embedded programming newbie and need some advice.
    I’m in process of making a "simon" type game: a game where an led array displays a random lighting sequence and the player tries mimicking it via button inputs.
    The rules of my game differ slightly from the standard simon, it uses more led’s, the leds’ are bi-colored, and the user is required to mimic display timing which unlike simon is non-uniform.

    Switch polling question:
    the ability to display led’s flashing on/off green and on/off red is integral to game play and therefore I need to be able to use the pause command several times within my program.
    My concern is that user input (momentary switch input) will be missed because it occurs during a pause.

    * Does anyone have advice on how to avoid switch poll misses?

    Interrupt question:
    I assume the 16F876 has at least 3 interruptible pins which would allow me to keypad my switches in such a way to trip an interrupt whenever a button is pressed.

    * Are interrupts fast?

    Timing is critical in my application.
    Will having interrupts going off every time a user hits a switch cause slowdowns?

    I might want to use TMR to capture player reaction times. Will interrupts stop or interfere with the clock?

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    > Switch polling question:

    > * Does anyone have advice on how to avoid switch poll misses?

    Avoid use of Pause or anthing else that will slow down your main program loop.

    > Interrupt question:
    > I assume the 16F876 has at least 3 interruptible pins...

    See Datasheet Section 12.10 especially 12.10.1 and 12.10.3.

    > * Are interrupts fast?

    'fast' is a relative term. 1uS using your 16F876-04/SP. But getting around to servicing the interrupt is a different story altogether.

    > Timing is critical in my application.
    > Will having interrupts going off every time a user hits a switch cause slowdowns?

    Not if your programming is any good.

    > I might want to use TMR to capture player reaction times. Will interrupts stop or interfere with the clock?

    Not unless you program it that way.

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  2. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  3. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10
  4. Replies: 14
    Last Post: - 26th September 2007, 05:41
  5. Newbie - 16F628A and switch latching
    By malc-c in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 19th May 2006, 02:35

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