MCP23S17 port expander

Need some help on a project you are working on or got stuck on a tutorial? Post your questions here.
Post Reply
Ryan7777
Posts: 1
Joined: March 21st, 2018, 6:14 am

MCP23S17 port expander

Post by Ryan7777 » March 21st, 2018, 1:19 pm

Hi there,

I have a project where I need to interface with a MCP23S17 port expander via SPI, actually several of them. But I figure I should start off with one and move on from there. My understanding of Verilog is nil. Lucid isn't really an option for me, unfortunately.

I've taken on a very ambitious task of redesigning a test setup from the ground up that was built using discrete logic that ends up driving a 14 bit parallel to synchro converter. I have the syncrho converters, so I just need to drive them in such a manner that they appear to have rotating output.
I.e. drive the 14 bit input with a binary number from 0 to 11111111111111.

I also have to do some switch reading and other tasks while all of this other stuff is going on in a synchronized manner or else I would save my sanity and just use a PIC! The problem with a microcontroller is that I need to generate some very short pulses. Which is probably why someone went through the trouble of designing the original equipment using discrete logic and a bunch of 555 timers...

I've looked hard at the visualizer shield design files and the SPI master module in particular, but it is so embedded in the overall design that I'm having trouble understanding it! It appears to be instantiated in the RTC module, which is instantiated in the control module, which is instantiated in the top module? It's hard to track that far backwards!

The tutorial code is just ripped out and posted, but the comments in the code don't really bother to explain what's going on very well. I guess if I was going to hammer on the embedded micro folks for something, it would be the fact that this Mojo board is geared towards beginners but is terribly great at helping with well commented code. But having a couple of books on Verilog, it seems par for the course I suppose.

I have used MCP23S17 with PIC's and AVR's and I understand that there are registers that need to be set before reading or writing to the ports on the chip.

I guess what I want to do is end up with a design that initializes the MCP23S17 to write to ports A and B, and then starts counting out of it in binary from 0 to 11111111111111 and then repeats. Having control over the speed of counting via one of the ADC inputs would also be helpful.

Any ideas where to begin?

embmicro
Site Admin
Posts: 834
Joined: March 24th, 2013, 12:45 pm

Re: MCP23S17 port expander

Post by embmicro » April 4th, 2018, 10:21 am

I'd suggest checking out the Lucid components in the Mojo IDE even if Lucid isn't an option for some reason. The SPI Master component follows the same structure as the Verilog one but is substantially less cluttered (thanks Lucid). That being said, neither of these are meant as an intro to Verilog/Lucid. I'd really recommend running through the Verilog tutorials in order to get a feel everything if you haven't already.

I'm not sure what your IO requirements are but if you just need to output more bits, a few shift registers would be substantially simpler to interface with.

Post Reply