Hi all,
This is a basic qustion regarding SDA and SCL pins.
Since both these pins are bidirectional these should pins need to be
tristated , so that the slave can acknowledge on SDA.
No, both pins are not bidirectional. Only the master device drives the SCK
line, and all slaves must leave their SCK's as input.
But i have seen in some docs that a '1' need to be converted to a 'Z'
while driving on SDA and SCL, what is the reason behind this????
Thanks in advance,
Praveen
As others have said, usually SCK and SDA have a 1-10k pullup resistor to Vdd.
This makes the signal a 1 while no device is pulling a pin low. So set the
output pin to a zero, and toggle it as being an input versus an output, to
generate your digital signal.
Since SCK is never "tristated", you can just drive it as 0/1 output using the
master device and omit the pullup resistor. Of course, the master device must be
able to source and sink a few mA. The PIC line of microcontrollers have no
problem doing this; the Atmels probably work the same.
Furthermore, if the Atmels have a pin which is "open collector output only",
then that would work for SDA without needing to tristate it. Just set it as an
output and "0" will pull SDA low, and "1" will release it (alowing the pullup
resistor to make SDA "1".)
For power-hungry applications, you can increase the pullup resistors at the
expense of speed and noise rejection. 100k works well for shielded,
battery-powered applications.
Cheers,
MCJ