MCP23S17 and BluePill Problem
Posted: Sun Nov 14, 2021 10:33 pm
Hi everyone guys, i've a problem keeping MCP23S17 in SPI mode working with my bluepill. I'm using the official arduino STM core (not the roger one) and this library https://github.com/MajenkoLibraries/MCP23S17. I've modified this library in the readPort(uint8_t port); function adding a parameter that can permit me to detect the MCP reading the IOCONA register as this
For first i've tested this code and library with the same HW (Cables, breakout board which this MCP is installed etc..) using an Arduino Mega. All worked perfectly, i've received my decimal 24 reading the IOCONA register and i tested it reading the GPIO expander. All fine. But going to the STM32 is going to made me crazy so i'm asking for help. I've tested using 3.3V and 5V source on MCP but i always read 0 in GPIO register and IOCONA register too.
I would prefer to use SPI2 interface, becouse after test a TFT ILI9486 will use the SPI1 PINS.
Thank you.
Code: Select all
uint8_t MCP23S17::readPort(uint8_t port) {
if (port == 2) {
readRegister(MCP_IOCONA);
return _reg[MCP_IOCONA];
}
if (port == 0) {
readRegister(MCP_GPIOA);
return _reg[MCP_GPIOA];
} else {
readRegister(MCP_GPIOB);
return _reg[MCP_GPIOB];
}
}
I would prefer to use SPI2 interface, becouse after test a TFT ILI9486 will use the SPI1 PINS.
Thank you.