MCP23S17 - Three different approaches - ShiftIn/ShiftOut / MSSP+PBP / MSSP+ASM


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,622


    Did you find this post helpful? Yes | No

    Default Re: MCP23S17 - Three different approaches - ShiftIn/ShiftOut / MSSP+PBP / MSSP+ASM

    Hi,
    I initially used the the SSPSTAT.0 bit for both sending and receiving but eventually got into trouble. Darrel then made me aware in this thread of that the purpose of SSPSTAT.0 flag really is when the PIC is operating in slave mode and data is shifted into to PIC by an external clock source, ie when something else is providing the SPI clock. (Thanks Darrel!)

    When the PIC is acting as the master, as is the case in all your examples, it works fine with the interrupt flag. For shifting in a byte you simply write a "dummy" value to SPPBUF, the module will then shift that dummy byte out with 8 clockpulses and then you'll have your input byte in SSPBUF.

    IF you're going to use the SSPSTAT.0 bit I suspect you want to poll it before reading SSPBUF to see if there's a byte available to be read. The way you have in your latest post you grab whatever is in SSPBUF and then sit there waiting for another byte before continuing. Is that the intentended operation?

    /Henrik.

  2. #2
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: MCP23S17 - Three different approaches - ShiftIn/ShiftOut / MSSP+PBP / MSSP+ASM

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    IF you're going to use the SSPSTAT.0 bit I suspect you want to poll it before reading SSPBUF to see if there's a byte available to be read. The way you have in your latest post you grab whatever is in SSPBUF and then sit there waiting for another byte before continuing. Is that the intentended operation?

    /Henrik.
    No, i actully take it of in my last version. Since the last thing that the MCP sends is the byte that i want, i just grab it and put it on the PORTB.
    Thanks and Regards;
    Gadelhas

  3. #3
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: MCP23S17 - Three different approaches - ShiftIn/ShiftOut / MSSP+PBP / MSSP+ASM

    You can find the last code on the WIKI.
    Thanks and Regards;
    Gadelhas

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