How to Read 6 Inputs anytime ?


Closed Thread
Results 1 to 10 of 10
  1. #1

    Question How to Read 6 Inputs anytime ?

    Hi all,
    I need your help in this subject , how to read 6 inputs as interrupt any time for PIC16F877A , beacuse our system entering in multiple sub routines so using polling way in main code not visible when our programm entering in another subroutine , so I can't know the change in these inputs.

    How I can solve this problem ?

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    http://www.picbasic.co.uk/forum/showthread.php?t=1367

    search enable port change interrupts
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    In order to understand the question properly,

    1. Do you need to know which one of the inputs caused the interrupt? or it does not matter?
    2. When you say "...I don't know the change in these inputs", do you need an interrupt when there is a "change" on at least one pin?

    - PORTB7:4 gives you four pins but you need six.
    -----------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4


    Did you find this post helpful? Yes | No

    Default

    oky I want to know which input is pressed so I decide what to do ?

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    So, you do not need a "change" on the pins.

    You have buttons and they can only be pressed, right?

    "Change" means =>
    If the button is pressed, there is a change. While the button is being pressed, there is no change.
    If the button is released, there is also a change.


    Are you sure you need interrupt to do this? any particular reason? Many people can solve their issues without using interrupt; simple pin readings can be more then good enough. This may be true in your case, may be.

    You may want to check the status of a port for all six pins.
    Last edited by sayzer; - 19th February 2008 at 15:52.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Sayzer,
    Looks like he wants an assembly interrupt to jump out of any running process.
    "beacuse our system entering in multiple sub routines so using polling way in main code not visible when our programm entering in another subroutine"
    looks like a job for instant interrupts.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Thanks
    I think sayzer understand what I mean, but I think without interrupt we can't know what button is presesd due to busy of my porgramm in other sub routines than main code

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


    Did you find this post helpful? Yes | No

    Default

    It sounds like you have more inputs than you have PORTB interrupt pins - or maybe your switches aren't connected to PORTB at all.

    In that case, you could write an interrupt routine on a timer. The interrupt would read all ports connected to the buttons into variables, then return from the ISR.

    Your main program can then (bitwise) AND the variables with a mask to pick out
    which button was pushed.
    Charles Linquist

  9. #9
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    iugmoh, Why not use 1 interrupt pin with a pullup resistor tied to as many diodes as you have switches. Then have 1 port change interrupt read the switch inputs and give the results? Why make it so complicated? Just a thought......

    Dave Purola,
    N8NTA

  10. #10
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dave View Post
    iugmoh, Why not use 1 interrupt pin with a pullup resistor tied to as many diodes as you have switches. Then have 1 port change interrupt read the switch inputs and give the results? Why make it so complicated? Just a thought......

    Dave Purola,
    N8NTA
    This is where I was going to go.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  2. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  3. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 06:34
  4. Real Time Clock & Eeprom
    By smart_storm in forum General
    Replies: 8
    Last Post: - 17th February 2006, 19:03
  5. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10

Members who have read this thread : 0

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