Comments (9)
No not tested, no HW nearby. And if it works I still doubt I would recommend it for the reasons mentioned earlier.
That said, if you need a lot of IO lines you can do 16 x 8 = 128 IO lines per select pin.
And if you use one MCP to control 16 select lines you could control 2048 IO lines in theory.
(in theory there is no difference between practice and theory, but in practice there is)
from mcp23s17.
This chip is the only SPI based one I know that has both an address and a SELECT line.
As within SPI one normally uses a SELECT line to select a device, this allows to have multiple device behind one.
When I would encounter such in a schema, it would immediately raise questions like:
- "are those selected simultaneously?"
- "sort of parallelism?"
- "is this correct?"
Only by studying the datasheet / code I will get an answer to those questions.
So in short it is outside my expectations.
That said, I think it is ok to use one select pin for multiple devices but never tested it.
If you do test it, please let me know your experiences.
(my assumption is that the address is inherited from the I2C version of the chip)
from mcp23s17.
If you do test it, please let me know your experiences.
I couldn't get it to work.
from mcp23s17.
looked into the datasheet
3.3.2 ADDRESSING SPI DEVICES
The MCP23S17 is a slave SPI device. The slave
address contains four fixed bits and three user-defined
hardware address bits (if enabled via IOCON.HAEN)
(pins A2, A1 and A0) with the read/write bit filling out
the control byte. Figure 3-5 shows the control byte
format. The address pins should be externally biased
even if disabled (IOCON.HAEN = 0).
TABLE 3-4: CONTROL REGISTER SUMMARY (IOCON.BANK = 1)
The library has no call for this, so you need to add something like code below to the library
(proto in .h and implementation in .cpp)
void enableHWAddress()
{
uint8_t reg = readReg(MCP23S17_IOCR);
reg |= MCP23S17_IOCR_HAEN;
writeReg(MCP23S17_IOCR, reg);
}
void disableHWAddress()
{
uint8_t reg = readReg(MCP23S17_IOCR);
reg &= ~MCP23S17_IOCR_HAEN;
writeReg(MCP23S17_IOCR, reg);
}
from mcp23s17.
Note to myself: better to make two generic control register calls
void enableControlRegister(uint8_t mask)
{
uint8_t reg = readReg(MCP23S17_IOCR);
reg |= mask;
writeReg(MCP23S17_IOCR, reg);
}
void disableControlRegister(uint8_t mask)
{
uint8_t reg = readReg(MCP23S17_IOCR);
reg &= ~mask;
writeReg(MCP23S17_IOCR, reg);
}
The defines should move from .cpp to .h
from mcp23s17.
@thijstriemstra
Created a branch - https://github.com/RobTillaart/MCP23S17/tree/develop
that supports the dis- / enableControlRegister(uint8_t mask) functions.
If you have time, can you please check verify if it enables the address stuff (I have no hardware around to test)
masks are in the MCP23S17_registers.h file.
from mcp23s17.
hi @RobTillaart thanks for taking the time to thoroughly investigate this. Due to time constraints I switched out the 2nd mcp23s17 with an I2C version (mcp23017) for now. I'm sure I'll run into this again in the future and will get back to you, cheers.
from mcp23s17.
OK, I will merge the branch and close the issue.
from mcp23s17.
thanks. I guess this info is now outdated (and tested instead)?
(not tested) Technically two chips could use the same select pin and a different address. The constructors would allow to setup such a configuration. I assume that this is less used and IMHO not recommended.
from mcp23s17.
Related Issues (20)
- Compilation for Arduino Nano 33 BLE fails HOT 6
- arduino-lint.yml workflow is not providing right status. HOT 1
- x16() functions don't work HOT 19
- No way to test for connection HOT 6
- Use of Interrupt Pins HOT 13
- Support for multiple Chips missing? HOT 13
- add keywords.txt
- Could I contact you with a help request for once? HOT 5
- MCP23S17 Daisy Chain On Common SPI Line HOT 13
- redo ESP32 SPI interface
- Arduino nano esp32 does not compile this library.
- remove hardware SPI end() begin() from library
- MCP.read(pin) always returns 1 HOT 11
- adding possibility to have à chipselect that is not directly from MCU but with though a chipselect decoder HOT 8
- Is the hardware address correct? HOT 4
- ESP32-C3 and MCP23S17 HOT 30
- add parameter to begin() to make INPUT PULLUP conditional.
- Using interrupts HOT 54
- How to enable hardware SPI on ESP32-S3 for this MCP23S17 libary? HOT 21
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mcp23s17.