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: Reading Output Port Register

Part Number: PCA9539

I have a question regarding reading the output port register. Whenver I read output port to verify it has correct data after writing, my polarity config regist 4 and 5 get reset. and I have to send reg 4 and 5 again.

Can I know if its usual thing to do after every read from output reg do i need to send reg 4 and 5 again?

  • Hey Saga,

    Just for clarity can you provide a schematic and also scope shots of your I2C transactions? I would like to verify you are writing to the correct registers.

    Thanks,

    -Bobby

  • Hi Bobby-

    I mean to say is that I communicating correctly as of now. Thge only problem is that when I write to output port reg (p1.0 -P1.7) I want to read the current status in PCA chip just to double-check if it has same state as intended. Is it possible to do that and it wont change polarity config reg right (reg 4 and 5)?

    Thanks,

    Sagar

  • Hey Sagar,

    "Is it possible to do that and it wont change polarity config reg right (reg 4 and 5)?"

    Yes. When you do a I2C read, that should not change the values the registers (it may clear data if you are reading the input ports but not the output ports or the polarity config reg).

    -Bobby

  • So reading output port regs won't affect input regs right? While I was reading output port registers, after that if I read input port regs read 0xFF instead of 0x00 which means polarity config registers were flipped. have you ever experienced this or is it common?

  • Hey Sagar,

    "So reading output port regs won't affect input regs right?"

    That is correct.

    "While I was reading output port registers, after that if I read input port regs read 0xFF instead of 0x00 which means polarity config registers were flipped. have you ever experienced this or is it common?"

    My guess is that you wrote to the output registers while the configuration register is set to an output. If you set all of the outputs to HIGH then all the inputs will see an output high and that will be reflected when you read the input port. (Output stage of the device is tied to the input stage of the device.) You can probe the output stages of the ports with a o-scope/DMM and compare them to input registers you read.They should match.

    -Bobby

  • "My guess is that you wrote to the output registers while the configuration register is set to an output. If you set all of the outputs to HIGH then all the inputs will see an output high and that will be reflected when you read the input port. (Output stage of the device is tied to the input stage of the device.) You can probe the output stages of the ports with a o-scope/DMM and compare them to input registers you read. They should match."

    So port 0-0.7 is input and P 1.0 to 1.7 is output. And polarity regs are written only for P0.0 -0.7.

    So when I write to P1.0-P1.7 and then I want to verify by reading this same Output port has the same value. So after reading this, it should not affect anything on P0.0 -p0.7 right even though I am reading it p1.0 to P1.7. But sometimes after reading P1.0-P1.7, Data on P0.0 -P0.7 gets fliiped (since it has polarity config set to 0xFF). So I this should not happen right?

    Thanks

    .

  • Sorry for such a long delay in getting back to you, I did not see this message until just now.

    "So when I write to P1.0-P1.7 and then I want to verify by reading this same Output port has the same value. So after reading this, it should not affect anything on P0.0 -p0.7 right even though I am reading it p1.0 to P1.7."

    That is correct. When you write and read the p1.0 - p1.7 it does not affect the other port.

    "But sometimes after reading P1.0-P1.7, Data on P0.0 -P0.7 gets fliiped"

    This does not sound right because you did not touch the P0.0 - p0.7 pins/register. Are those pins referenced to gnd/Vcc through a resistor or set to outputs? It is possible for these input values to change if the pins are left as inputs and floating.

    -Bobby