This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PCA9539: INT pin is not getting high

Part Number: PCA9539
Other Parts Discussed in Thread: MSP430F4784,

Hi,

I'm trying use additional GPIOs for my board ( MSP430F4784), So I'm using PCA9539 I/O expander 16 bit.

As per the datasheet I programmed using I2C.

I'm using 0x74 as slave address as I grounded A0 and A1.

I'm able to read and write data in PCA9539 on step by step debugging.

For interrupt pin I used controller's interrupt pin. But when I run the below program after POR the interrupt pin is not getting high and I'm not even changing pin state in I/O expander.

also interrupt is not happening even though the pin in low condition.

Can you provide any example for PCA9539 other than arduino example. Like MSP430 series.

Or please provide me procedure to work on PCA9539. 

void i2c_beginTx(uint8_t address)
{
    UCB1I2CSA = address;
    UCB1CTL1 |= UCTR + UCTXSTT;
    while((UCB1STAT & UCNACKIFG));
}

void i2c_write(uint8_t byte)
{
    __delay_cycles(500);
    UCB1TXBUF = byte;
    while((UCB1STAT & UCNACKIFG));
}

void i2c_read(uint8_t address, uint8_t reg, uint8_t len)
{
    int i;

UCB1I2CSA = address;
UCB1CTL1 |= UCTR + UCTXSTT;
while((UCB1STAT & UCNACKIFG));
UCB1TXBUF = reg;
__delay_cycles(500);
UCB1CTL1 |= UCTXSTP;

UCB1I2CSA = address;
UCB1CTL1 &= ~UCTR;
UCB1CTL1 |= UCTXSTT;
while((UCB1STAT & UCNACKIFG));
for(i=0;i<len;i++)
{
    data[i] = UCB1RXBUF;
    __delay_cycles(500);
}
UCB1CTL1 |= UCTXNACK;
UCB1CTL1 |= UCTXSTP;
}

void read(uint8_t address, uint8_t len)
{
    UCB1I2CSA = address;
   UCB1CTL1 &= ~UCTR;
   UCB1CTL1 |= UCTXSTT;
   while((UCB1STAT & UCNACKIFG));
   for(i=0;i<len;i++)
   {
       //delay_in_sec(1);
       data[i] = UCB1RXBUF;
       __delay_cycles(500);
   }
   UCB1CTL1 |= UCTXNACK;
   UCB1CTL1 |= UCTXSTP;
}

void i2c_stop()
{
    UCB1CTL1 |= UCTXSTP;
}

int main()
{
    WDTCTL = WDTPW | WDTHOLD;
    
    P4SEL |= BIT3 + BIT4; // i2c pins
    
    /** interrupt  pin **/
    P1DIR &= ~BIT7;
    P1IE |= BIT7;
    P1IES |= BIT7;
     
     P9DIR |= BIT5; //LED blink
     
    UCB1CTL1 |= UCSWRST;
    UCB1CTL0 |= UCMST + UCMODE_3 + UCSYNC;
    UCB1CTL1 |= UCSSEL_2 + UCSWRST;
    UCB1BR0 = 11;
    UCB1BR1 = 0;
    UCB1CTL1 &= ~UCSWRST;

    __delay_cycles(100);

    i2c_beginTx(0x74);
    i2c_write(0x06);
    i2c_write(0xFF);
    i2c_write(0xFF);
    i2c_stop();



    while(1)
    {
     i2c_read(0x74, 0x01, 2);
    }

}

#pragma vector=PORT1_VECTOR
__interrupt void port_1_ISR(void)
{

if(P1IFG & BIT7)
{
    read(0x74, 2);
    if((data[0] & 0) == 0)
    {
    P9OUT |= BIT5;
    __delay_cycles(1000000);

    P9OUT &= ~BIT5;
    __delay_cycles(1000000);
    }
    P1IFG &= ~BIT7;
}
}

  • Sai,

    Do you have a schematic we can check? The INT pin is an open drain output and requires an external pull up resistor to provide a logic high.

    -Bobby

  • unfortunately I'm unable to provide schematic.

    For interrupt pin I provided 10K Pull up resistor. Is that enough?

    For 1Mhz clock INT is getting high now. But I want this to work on 8Mhz, so I have included some delays also, but sometimes INT becomes always low or reading I/Os becoming an issue like initially when a high is there making it low or press button. INT responding accordingly but after 3rd or fourth time pressing button interrupt becomes always low.

  • Hi Sai,

    For interrupt pin I provided 10K Pull up resistor. Is that enough?

    Yes 10k should be fine.

    but sometimes INT becomes always low or reading I/Os becoming an issue like initially when a high is there making it low or press button.

    The INT should always deassert after you read the input ports. You shouldn't be seeing INT remain asserted if you are reading those ports after each INT assertion. Do you have a scopeshot of the INT assertion with the I2C traffic showing a read of the input ports?

    -Bobby