• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Arduino and Port Expanders MCP23008/17

Status
Not open for further replies.

Wp100

Well-Known Member
Hi,

Am trying out one of these port expanders with a 5v Uno /Nano in order to reduce the footprint of the full project rather than using the Mega2560.
http://robotic-controls.com/learn/electronics/io-port-expander-mcp23017-and-mcp23008

While the above example is good and clear for directly addressing the ports of the MCP chip, wondered if there was any way to it with existing libraries ?

eg, we are using a ILI9341 TFT and its RST and CS pins are 'slow' signals so seem ideal for output though the MCP, but unable to see from our limited code knowledge if there is any way to readily achieve this.

Same when using an input sensor like a DS18B20 library, is that at all possible without major modification to the library itself ?

#define TFT_RST 7
#define TFT_DC 8
#define TFT_CS 10
#define TFT_MOSI 11
#define TFT_MISO 12
#define TFT_CLK 13
// Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
// Use hardware SPI (on Uno, #10, #9, #11, #13, #8, #12)

(the Uno is fast enough to drive the tft display for our project needs)

thanks
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
eg, we are using a ILI9341 TFT and its RST and CS pins are 'slow' signals so seem ideal for output though the MCP, but unable to see from our limited code knowledge if there is any way to readily achieve this.
So you have an eight bit parallel library and you want to modify it to SPI?... Some of those TFT's support direct SPI and the libraries are already written.... How big is the screen... Worst case! Yes you can modify the library t output via a MCP230017....
 

JonSea

Well-Known Member
Most Helpful Member
The MCP23008 and MCP23017 are I2C, not SPI. SPI versions are available (MCP23S08 and MCP23S17).
 

Wp100

Well-Known Member
So you have an eight bit parallel library and you want to modify it to SPI?... Some of those TFT's support direct SPI and the libraries are already written.... How big is the screen... Worst case! Yes you can modify the library t output via a MCP230017....
Hi,

No, its already running on SPI using the Adafruit set up, with the 3 spi lines plus D/C and the CS and Reset pins
https://www.adafruit.com/product/2478

Its just that our program, originally written on the mega2560 uses libraries for most of its functions.

I've been trying to run the program on the smaller Uno /Nano** but we are 2 pins short for the library functions, eg 8 input sensors, 4 pwm outputs, 6 i/o for the TFT , 2 for I2C and 2 for comms.

We can use the Expander chip for directly coded control of the other outputs, but we really need to move 2 pins from direct library control and the TFT CS and RST seem the best ones. ( CS could be hardwired low as nothing else on SPI and Reset on low, is said to be not required, but have tried various code combinations to the above but it does not like to run without them ?)

Yes you can modify the library t output via a MCP230017....
We are only C++ beginners, is it that easy to modify a library such as the adafruit one to output CS and RST to the MCP chip ??
Any pointers appreciated.
https://github.com/adafruit/Adafruit_ILI9341

thanks

** our friend has written the code with a little help from me and he has done a pcb to act as a very large shield to the mega2560, but it would be much better if we could reduce the size by running it on the nano with a MCP chip.
The code runs does run ok on the nano and the tft display is still fast enough, its just a way of freeing 2 i/o pins to the MCP chip.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
C++ is able to compile C so any C library and be used... I have messed with SPI MCP23 and I2C MCP23 chips..

BTW a simple 74hc595 could be used to control CS... However!! I never use the CS pin if there is only 1 SPI device... I just ground it out Same with the RST....
 
Last edited:
Status
Not open for further replies.

EE World Online Articles

Loading
Top