Reading the port - Little help needed


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2009
    Location
    London
    Posts
    251

    Default Reading the port - Little help needed

    I would like to ask if someone can suggest me how should I write the following statement as the current one is not working:
    Code:
    	
    While PortC=%111011 & %001000
        Serout ToTx,N2400,[66]
    wend
    I want to check if ONLY PortC.2 is pulled low & rest are held high. I want to exclude PortC.3 from being read as it has another function attached to it. It's state (PortC.3) should not be considered. Thanks

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Reading the port - Little help needed

    Code:
    WHILE (PORTC = %11111011) OR (PORTC = %11110011)
              SEROUT ToTx, N2400, [66]
              WEND
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Reading the port - Little help needed

    or
    Code:
    WHILE (PORTC = %11110011 | %00001000)
              SEROUT ToTx, N2400, [66]
              WEND
    probably what you wanted to do at first
    Last edited by mister_e; - 26th June 2011 at 14:33.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default Re: Reading the port - Little help needed

    "| %0000100"
    What does this does mister_e? I read the manual it says there that this "|" is used to set the bit. Please explain how it fits with my requirement. Thanks a lot

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Reading the port - Little help needed

    it's all about Bitwise operations.

    | is bitwise OR.

    You said you don't need to monitor bit.3?

    So it could be 0 or 1?

    How about making sure this specific is always 1 then?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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