Two Bit request (sic)


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Lots of ways to do this, here’s one:

    If the pins are two adjacent pins of a port (for example portA.2 and porta.3) then you could use a bit mask and then shift the bit to the right as needed. So, using A.2 and A.3 it would be:
    Code:
    MODEval= PortA & %00001100
    MODEval = MODEval >> 2
    This will give you a value of MODE from 0-3.

    Also, you would even skip the shift and just use the CASE to check for values of 4, 8, and 12.

    And, if the pins are not consecutive, you can still use a bit mask and then check the values:
    Code:
    MODEval = PortA & %10001000
    SELECT CASE MODEval
    	CASE 8
        		Statement... 
    	CASE 128 
        		Statement...
    	CASE 136 
        		Statement...
    	{CASE ELSE 
        		Statement...}
    END SELECT
    HTH,
    SteveB

  2. #2
    Join Date
    Jan 2007
    Posts
    24


    Did you find this post helpful? Yes | No

    Thumbs up

    Thanks for the rapid reply. I've used this method before many times,and probably will in this case too, so couldn't believe I missed it =-) nvm.

    No all I gotta do if figure out how to attach 4 swiches per port. It's a LONG time since I did any programming and I forget a lot of the techniques involved (happens when you get old).

    Thanks Steve that was a great help.

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Doubt with interrupt on change
    By lugo.p in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th March 2010, 15:22
  3. How to receive stream of bytes using PIC USART
    By unifoxz in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 20th June 2009, 10:38
  4. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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