MCP23S17 and an LCD Display
G McMurry
Posts: 134
This forum is fantastic.
I have solved so many problems with a quick question here. I thought I would give this one a try.
I have an application similar to the Nuts & Volts EXPANSION MADE EASY Column #109. I was able to find someone selling a nice 2X16 LCD Display that has a MCP23S17 as an interface. For my application, I need to conserve all the IO I can with my BS2p (or maybe a BS2). Therefore the idea of only using three IO pins seemed good.
I found the Nuts & Volts article Column #109 called Expansion Made Easy but it uses an MCP23016. I thought for sure I would be able to find some sample code using the MCP23s17 but so far no luck.
Can anyone help me here?
THANKS
Greg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net
I have solved so many problems with a quick question here. I thought I would give this one a try.
I have an application similar to the Nuts & Volts EXPANSION MADE EASY Column #109. I was able to find someone selling a nice 2X16 LCD Display that has a MCP23S17 as an interface. For my application, I need to conserve all the IO I can with my BS2p (or maybe a BS2). Therefore the idea of only using three IO pins seemed good.
I found the Nuts & Volts article Column #109 called Expansion Made Easy but it uses an MCP23016. I thought for sure I would be able to find some sample code using the MCP23s17 but so far no luck.
Can anyone help me here?
THANKS
Greg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net
Comments
I just can't seem to get the thing running at all. I need help understanding the initialization.
It would seem this would be a popular product. 16 I/O bits for under $2.00
Greg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net
I am not even trying to READ the MCP23S17 yet. No connection there... I will go back and look at the Nut's N Volts article again. It seemed to me that the difference between the two devices was considerably different.
I have a simple wiring... A0-A2 gounded. R/C on the reset pin (it resets every time it gets turned on. I have control over /CS, SCK and SI.
My first experiments, all I want to do is set GPA0-7 as outputs and write to them.
It is my understanding that each instruction takes 3 bytes. Opcode / Register / Data
My first assumption was that all I would need to do was the following:
Upon reset, the MCP23S17 comes up IOCON BANK=1 I use addresses for Bank=1
OpCode $41
IOCON $05 turn off sequential operation
Data $40
OpCode $41
IODIRA $00
Data $00 make port A output
OpCode $41
OLATA $0A
Data $55 send outputlatch for port a 01010101 $55 (an easy to see value on a row of leds connected to GPIOA
Here is my SPI Sub-Routine in PBasic
delaytime = 10
write_MCP:
FOR index = 7 TO 0
IF index < 8 THEN Put_Digits
GOTO noop1
Put_Digits:
LOW CS
PAUSE Delaytime
SHIFTOUT SI, SCK, MSBFIRST, [noparse][[/noparse]mcp_data]
PAUSE Delaytime
HIGH CS
NEXT
noop1:
RETURN
PS Thanks for your terrific help in programming my MAX7219 Display Driver.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net
LOW CS
SHIFTOUT SI,SCK,MSBFIRST,[noparse][[/noparse]$40,$00,$00] ' make port A outputs
HIGH CS
LOW CS
SHIFTOUT SI,SCK,MSBFIRST,[noparse][[/noparse]$40,$14,$55] ' set port A output latches to $55
HIGH CS
I am now getting something though not exactly what I expected. But enough for me to poke at. I thought that we would need to set the OpCode byte to $41 to set the R/W bit to W but I see the error in my thinking there. AND I was over thinking the BANK issue. Of course you are correct...
I will mess with this some more. Again, thanks for your help.
Greg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net
Now on with the LCD... (grin)
Greg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net