How to Correctly define Shiftout bits


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2010
    Posts
    14

    Default How to Correctly define Shiftout bits

    This works for me
    Shiftout SDO,SCK,Msbfirst,[WR_OPCODE_BYTE,IODIRA,$00\24]

    but from what I'm seeing in the manual it is not correct. Also from looking on this forum it is not correct from what I can tell.

    This does not work for me
    Shiftout SDO,SCK,Msbfirst,[WR_OPCODE_BYTE\8,IODIRA\8,$00\8]

    This does not work correctly either
    Shiftout SDO,SCK,Msbfirst,[WR_OPCODE_BYTE,IODIRA,$00]

    I need to shift out 24 bits. What is the correct way to pass the number of bits sent?
    Again Shiftout SDO,SCK,Msbfirst,[WR_OPCODE_BYTE,IODIRA,$00\24] works but not sure why. The other ways do not.

    Help is greatly appreciated.
    Thanks,
    Bryan

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: How to Correctly define Shiftout bits

    This shifts out 2 bytes followed by 24-bits all zeros;
    Shiftout SDO,SCK,Msbfirst,[WR_OPCODE_BYTE,IODIRA,$00\24]

    This shifts out 3 bytes;
    Shiftout SDO,SCK,Msbfirst,[WR_OPCODE_BYTE\8,IODIRA\8,$00\8]

    This shifts out just 3 bytes;
    Shiftout SDO,SCK,Msbfirst,[WR_OPCODE_BYTE,IODIRA,$00]

    If you need 2 bytes WR_OPCODE_BYTE & IODIRA followed by 24-bits, then simply use the first version.

    As in the manual, if you don't specify the number of bits, then 8-bits are shifted out. If WR_OPCODE_BYTE & IODIRA are byte variables with only 8-bits, then you don't need to tell it to shift out 8-bits per variable. It's automatic.

    If either one was larger than 8-bits, then you would need to specificy this with the /#bits here option.

    And - if you need 24 x 0 bits shifted out after the 1st two variables, then neither of your other routines are going to do that, so it doesn't work.

    In your 1st version you're shifting out a total of 5 bytes. In your 2nd two just 3 bytes.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Jul 2010
    Posts
    14


    Did you find this post helpful? Yes | No

    Default Re: How to Correctly define Shiftout bits

    I'm shifting out 24 bits. The device I writing to is a I/O portexpander MCP23S17 from microchip. I've tried the other methods and the portexpander does not respond to them. The only way to get it to recognize any commands, was to send them out like this.

    WR_OPCODE_BYTE con $40
    INTCONA con $04

    Shiftout SDO,SCK,Msbfirst,[WR_OPCODE_BYTE,IOCONA,$A0\24]

    I don't know what the problem is with this. I know now it is incorrect but it works. The other ways do not.

    There are two programs I wrote using the portexpander in PicBasic Pro. The first one only works as stated above. The other one works correctly if I use
    Shiftout SDO,SCK,Msbfirst,[WR_OPCODE_BYTE,IOCONA,$A0]. Both use pretty much exactly the same code as it was copied and pasted from the first program into the second one. I can't put all the code on here as it was over 3000 lines of code.

    Thanks,
    Bryan

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: How to Correctly define Shiftout bits

    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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