Very nifty I2C trick!

fernando_g

Senior Member
I found a very neat way to view the I2C signals on the PICAXE VSM, and would like to share in this forum, to pay back all the good info I've received here.

The Picaxe VSM has a very powerful I2C debugger tool, which nevertheless can be a little daunting to the novice wishing to learn more about the protocol.
I know , because that happened to me.

It is sometimes useful to view not only the coded message, but the actual waveforms with an oscilloscope. Fortunately, VSM will allow you to simultaneously connect both the I2c debugger tool and the oscilloscope.

However, anybody who has attempted to view an I2C signal with a scope (either in a simulator or in an actual physical device) is stumped how to trigger the scope.
Which signal -SCL or SDA- is best to use as a trigger? The short answer is none.

I2C is a very clever but complex protocol with a fair amount of handshaking and acknowledges between devices. But there is a key signal: the start preamble defined as pulling the SDA line low while holding SCL high.
If one could trigger from that event, then the whole I2C telegram becomes clear. Is a little like looking for a capital letter that marks the beginning of a sentence.
No affordable scope, and certainly not VSM's virtual scope support multichannel-event triggering. But browsing thru the internet I found a little circuit, made with an inverter and a flip-flop, that can fetch such a signal.
I modeled it in VSM, and it works!! See the attached schematic and scope image.

I wrote a very simple program... that all it does is to load into an external 24LC16B memory's locations 1 thru 10, the numbers 11 thru 20. After a brief pause, it will read them back.
By using breakpoints, one can step thru each I2C telegram, and simultaneously read the acronym in the debug tool and view the bits changing on the scope.
One can view the start sequence, the individual bits being clocked in, the clock stretching to identify an acknowledge, etc. Very neat way to understand I2C's physical layer!!
 

Attachments

hippy

Technical Support
Staff member
Brilliant trick and one which would work in the real world as well as the virtual one. Thanks for sharing.
 

Labcenter

New Member
ISIS actually supports 'hardware breakpoints' quite extensively, both through standard single wire voltage probes and also, for more complex conditionals, through dedicated widgets.

You could, for example place an RTDBREAK_2 widget (pick from libs) wire to the lines and set the trigger value to be 0x03 to achieve the same effect.

Iain.
 
Top