1
\$\begingroup\$

I have an EEPROM following I2C protocol. My write operation was fine. While a read operation, SDA being my inout pin, during data transfer from slave, I held the pin in high impedance (Z).I received logic zero correctly but not logic ones.Clock cycles where logic 1 was expected, were showing up high impedance state.

My question is for data transfer from slave to master, should master hold the inout pins in high impedance state? If yes then why is that when data is logic 0, cycles are showing up but when data is 1, still high impedance is observed.

Is there any other value should this inout pin be assigned to so that logic 1 and logic 0 are properly transmitted?

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

Since you are 'observing' high impedance, I take it this a simulation and not a real circuit.

In these cases, place a pullup on both sda and scl in your testbench (which presumably connects your i2c module with the eeprom model).

\$\endgroup\$
3
  • \$\begingroup\$ Yes, you are correct. I am simulating the setup. Perhaps, if I add a pullup, I am losing the acknowledge from slave. \$\endgroup\$
    – san6086
    Commented Oct 13, 2012 at 12:22
  • \$\begingroup\$ tinypic.com/r/qpgojk/6 please have a look at the problem \$\endgroup\$
    – san6086
    Commented Oct 13, 2012 at 12:30
  • \$\begingroup\$ Please find my code here textuploader.com/?p=6&id=8elO6 \$\endgroup\$
    – san6086
    Commented Oct 13, 2012 at 14:16
0
\$\begingroup\$

VHDL provides a solution using 9-state logic (STD_LOGIC type):

For I2C pins, and any other open-drain pins (weak pull-up), you should drive H and 0 (not Z). If any signal is simultaneously driven with H and 0, the 0 will win (as you desire) and you will not get X like you would between conflicting 0 and 1. And then use the TO_X01 function when reading the signal, to resolve H to 1.

I would look to see whether Verilog has any logic type which supports weak states.

\$\endgroup\$
3
  • \$\begingroup\$ Verilog doesn't have weak states. It only has 1, 0, and Z. But it does have weak drivers, which will pull a signal out of Z state but won't cause an error if they conflict with a stronger driver. It also has tri1 and tri0 net types with implied pull-up or pull-down, and it also has pullup and pulldown "gates". \$\endgroup\$
    – The Photon
    Commented Oct 13, 2012 at 17:27
  • \$\begingroup\$ @ Ben Voigt - How can I assign a value 'H' to a pin? \$\endgroup\$
    – san6086
    Commented Oct 14, 2012 at 1:38
  • \$\begingroup\$ @san6086: See ThePhoton's comment... Verilog uses a different approach from VHDL. \$\endgroup\$
    – Ben Voigt
    Commented Oct 14, 2012 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.