Continue to Site

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.

  • 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.

IO Expanders MCP23008

Status
Not open for further replies.

SneaKSz

Member
Hi all,

Im facing a stupid problem, I'm able to initialise my I2C IO expander :MCP23008 (https://www.electro-tech-online.com/custompdfs/2011/02/21919d.pdf) .

I'm unable to get an interrupt, but I"m able to set different ports high and low. I cant find the fault.

I want to have an interrupt when an input change from state ( port 7->4). As you can see in the code , Ive set them as input , enabled the interrupts. But the interrupt is always high, and Ive set it as active HIGH , so there is always an interrupt.


Hopefully someone can help me with this problem !

Code:
void main(void){

init();// setup
	Delay10KTCYx(300);// wait 333ms startup GPIO
while(1){
	SendByte(0x40,GPIO,0xF0); 
         Delay10TCYx(1);
	SendByte(0x40,IOCON,0b00110010);  // active high
	Delay10TCYx(1);
	SendByte(0x40,IODIR,0xF0); //WriteAddress iodir , high nibble input	
        Delay10TCYx(1);
	SendByte(0x40,INTCON,0xF0); // compare to def val
          Delay10TCYx(1);
	SendByte(0x40,DEFVAL,0xF0);// def val to compare
        Delay10TCYx(1);
	SendByte(0x40,IPOL,0x00); // same pol 	
        Delay10TCYx(1);
	SendByte(0x40,GPPU ,0xFF); 
        Delay10TCYx(1);
	SendByte(0x40,GPINTEN,0xF0); // enable input pin for inter on change	
}
while(1);
!

My I2C pulses are correct !

Hopefully someone can help me !

With kind regards
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top