connecting MCP23017 extender to STM32F4 DISCO communication/testing
Hello!
I am trying to connect 8 mcp23017 gpio extenders daisy chained to stm32 but I am having difficulty testing the validity of the ports. I configured the extender and set up the pins to be output pins but when I send the data to write active high to all the ports of the extender, I get no output... what I might be missing here? Is there anything I am fundamentally doing wrong? The extender I am testing the ports with the code below has address 0 (and the base address is 0x20) I would appreciate any kind of help/tips! I included my code below:
thank you!
uint16_t devAddr = 0x80; //addr for the first mcp23017 device opcode
//register addresses (memAddress) in mcp23017
uint16_t configMem = 0x05; // addr for the IOCONFIG register in the device (set up the bank)
uint16_t ioDirAMem = 0x00; //set up the direction of the port A pins on mcp23017
uint16_t ioDirBMem = 0x10; //set up the direction of the port B pins on mcp23017
uint16_t gpioB = 0x19; //GPIOB register to be written in order to send data to mcp23017
//size of internal mem address is 1 byte so (I2C_MEMADD_SIZE_8BIT)
//data to be sent
uint8_t dataConfig = 0xE2; //input as &data to the function to give the pointer
uint8_t dataIODIR = 0x00 ; //set all pins as output
uint8_t dataSent = 0xFF; // data to send to turn on the ports (all 1)
HAL_I2C_Mem_Write(&hi2c1, devAddr, configMem, I2C_MEMADD_SIZE_8BIT, &dataConfig, 1, 1000); //configure the registers - bank 0/1 (0x05 - iocon)
HAL_I2C_Mem_Write(&hi2c1, devAddr, ioDirBMem, I2C_MEMADD_SIZE_8BIT, &dataIODIR, 1, 1000); // input output config (0x00 (port A) - 0x10 (port B))
HAL_I2C_Mem_Write(&hi2c1, devAddr, gpioB, I2C_MEMADD_SIZE_8BIT, &dataSent, 1, 1000); // write to the port B of the third mcp23017 (send active high to 0x19 (GPIOB for bank1)