I can do basic IO on this chip without any issues but can i get the interrupt to work, no. Been at it for a few days and im not making any progress, please help!!!!
Hardware setup:
NP2+, clk & data lines have pull up resistors, 2 leds on the output of the mcp chip. 2 simple switch for the input with pull up resistors which is shorted to ground when switched. INTA on the mcp has a direct connection to the NP2+ to DIO0.
private void SetupPort(Port port){byte IODIA = IODIRA;byte IOCONAddress = IOCON;byte GPINTENAddress = GPINTENA;byte INTCONAddress = INTCONA;byte INTCAPAddress = INTCAPA;byte DEFVALAddress = DEFVALA;if (port == Port.PortB){IODIA = IODIRB;GPINTENAddress = GPINTENB;INTCONAddress = INTCONB;INTCAPAddress = INTCAPB;DEFVALAddress = DEFVALB;}// I/O expander configuration 1010 0000this.device.Write(new byte[] { IOCONAddress, 0xA0 });// Interrupt on change pin 00001111 first 4 are enabled only cus they are inputsthis.device.Write(new byte[] { GPINTENAddress, 0x0F });// default value to compare before the interrupt hitsthis.device.Write(new byte[] { DEFVALAddress, 0x0F });// Interrupt on change control reg, interrupts on default valuethis.device.Write(new byte[] { INTCONAddress, 0x0F });// clear the interupt capture regbyte[] ReadBuffer = new byte[] { INTCAPAddress };this.device.Read(ReadBuffer);// Direction register 11110000 first 4 are outputs and the rest are inputsthis.device.Write(new byte[] { IODIA, 0xF0 });// set outputs to 0//SetIOPort(port, 0);}
basicaly the setup is the first 4 bits to be inputs (interrupt driven) and the next 4 bits as outputs.
ive configured to only go high when it receives a high level from the input.
Its not working at all.