Quickest way to get highest set bit on port in to a variable?


Results 1 to 29 of 29

Threaded View

  1. #14
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: Quickest way to get highest set bit on port in to a variable?

    I may be wrong but I don't think this will work.
    LOOKDOWN2 Search,{Test}[Value{,Value...}],Var

    Lookdown2 compares the value of "Search" with the values in the list from left to right (index values 0 up to 255) with the "Test" comparison.

    So if "Search" = 5 and "Test" = "=>" then using your values for the Value in the list, the logic tests should look like this.
    (Values: 0, 1, 2, 4, 8, 16, 32, 64, 128) bits 0-7
    Test 1: is 5 => 0? : Yes, (0 will be stored in Var)
    The testing would stop right here for every value of "Search" (0-255) for bytes (0-65535) for words because the "Search" value will always be greater than or equal 0 (unless you're using Long variables)

    Maybe I'm wrong?

    As I see it, to use Lookdown2 you would still need to enter all the values from 0 to 255 inclusive into the list.
    And "Test" would need to be set to "="
    Lookdown2 supports up to 85 values in the list or up to 256 when using a PIC18.
    Last edited by Tabsoft; - 4th March 2015 at 02:03.
    Regards,
    TABSoft

Similar Threads

  1. Replies: 6
    Last Post: - 18th July 2012, 02:42
  2. Whats the quickest way to set bits?
    By bearpawz in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 26th October 2010, 04:38
  3. Bit set question
    By nverma in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd April 2007, 21:23
  4. set flags within a variable?
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 24th October 2006, 11:07
  5. How do I to set one bit in a register?
    By jessey in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th February 2006, 08:43

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