Need to flip order of bits MSB to LSB re: MCP23S17


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Need to flip order of bits MSB to LSB re: MCP23S17

    Using two bytes (PBP alias) I don’t think costs you any time even behind the scenes,
    and then just addressing them in the order you want would be the next best thing to swapping the hardware.
    I’m not familiar with the device, but if REV didn’t work as you expected, it sound like swapping bytes was the solution?

    If that’s wrong, and it’s back to reversing bits, there’s no math to do it,
    it’s always whacky procedural code emulating what a Human would do.
    You can use the above method first (almost free), and then logical operators,
    but it’s essentially the same goal as moving a ball around a table with paper cups.

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Need to flip order of bits MSB to LSB re: MCP23S17

    I’ve got to do it this weekend, and don’t get to use REV, so this is what I came up with (untested).
    There’s another thread about REV somewhere.. it was decompiled to find out instruction time,
    and I don’t know right now If I’m beating it.

    Code:
    sixteenbit var word
    revsixteen var word
    
    leasteight var sixteenbit.byte0
    mosteight var sixteenbit.byte1
    leastrev var revsixteen.byte0
    mostrev var revsixteen.byte1
    
    count var byte
    
    
    reversesixteen:
    
    for count = 0 to 7
    
    leastrev.bit7 = mosteight.bit0
    mosteight << 1
    leastrev >> 1
    
    mostrev.bit7 = leasteight.bit0
    leasteight << 1
    mostrev >> 1
    
    next count
    
    return

Similar Threads

  1. shiftin with \bits - What order do they come?
    By tbarania in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd April 2015, 04:39
  2. MSB Compile error
    By RFEFX in forum PBP3
    Replies: 2
    Last Post: - 26th January 2015, 06:32
  3. Replies: 2
    Last Post: - 23rd April 2013, 16:34
  4. Toggled Pic flip flop Help Please
    By g7jiq in forum General
    Replies: 2
    Last Post: - 22nd March 2009, 10:09
  5. Flip Flop
    By tazntex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th November 2008, 20:53

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