Author Topic: MCP23S17 SPI extender - it works but not totally satisfied  (Read 5163 times)

0 Members and 1 Guest are viewing this topic.

Offline netdudeukTopic starter

  • Frequent Contributor
  • **
  • Posts: 462
  • Country: gb
MCP23S17 SPI extender - it works but not totally satisfied
« on: October 15, 2013, 04:14:44 pm »
Hi

I've got an Arduino project where it drives an SPI version of the MCP23S17 bus extender (http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf).  It's just a POC before I hook it up to a microprocessor to drive the buses.

I was originally using the MC23S17 Class (http://playground.arduino.cc/Main/MCP23S17) but prefer to run my own code, for a better understanding.

So, to see how little programming the MC23S17 needed, I sniffed the bus while sending a value to the output pins and this is what I got from the library version and the raw SPI library version (which is a set of SPI transfers based on what I saw in the class version of the capture).

The only obvious difference in function is that the class version sends one value (1) to the outputs and the library sends another (5), for clarity.  LEDs confirm this.

However, when looking at the SPI captures, there are a couple of things that seem odd.

Firstly, while it looks like the 64 0 0 0 sets up ports to be outputs, and the 64 18 x x writes the data to the output pins, it's not clear what the 64 10 8 does.  I'm thinking that it's updating the IOCON.HAEN flag to say use the user specified hardware address but the MCP23S17 has all the address pins pulled low.   This command sequence is definitely needed as the SPI library version of the code does not work without it.

Secondly, the class version of the data shows 64 18 1 0 while the SPI library version shows 64 18 0 5.  Why would it be that if the last two bytes are not reversed in the second example, it doesn't work (three LEDs all off, as if we're seeing the 0 and not the 5) ?

Thanks

 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7938
  • Country: nl
  • Current job: ATEX product design
Re: MCP23S17 SPI extender - it works but not totally satisfied
« Reply #1 on: October 15, 2013, 05:47:27 pm »
OK. You have the datasheet. You also have a source code, it is in the library, the *.CPP file. Open it, read it. It has comments like every single line, which are longer than the Lord of the Rings. Why do you need us, and the logic analyzer?
 

Offline netdudeukTopic starter

  • Frequent Contributor
  • **
  • Posts: 462
  • Country: gb
Re: MCP23S17 SPI extender - it works but not totally satisfied
« Reply #2 on: October 15, 2013, 05:58:05 pm »
Because I didn't realise that the source code was in there ?

That should do it thanks.
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8550
  • Country: us
    • SiliconValleyGarage
Re: MCP23S17 SPI extender - it works but not totally satisfied
« Reply #3 on: October 15, 2013, 06:10:21 pm »
Because I didn't realise that the source code was in there ?

That should do it thanks.

Isn't that the whole point of 'open source' ?  :palm:
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline netdudeukTopic starter

  • Frequent Contributor
  • **
  • Posts: 462
  • Country: gb
Re: MCP23S17 SPI extender - it works but not totally satisfied
« Reply #4 on: October 15, 2013, 06:16:04 pm »
Isn't that the whole point of 'open source' ?  :palm:

Surely better to not reply than to be negative ?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf