Filip Mulier

Posting some example code for QG8 IIC

Discussion created by Filip Mulier on Mar 10, 2008
Latest reply on Jun 23, 2010 by Van Truong
Up to now I've failed to find good examples of I2C code for the QG8 (or other HCS08) 8-bit processors that fully take advantage of the IIC interrupts and work for both master and slave.  Most examples have been minimal (AN3048) or have not provided a complete master/slave solution (AN3291).  The closest example is AN2318 for the HCS12 (which uses the same IIC peripheral). 
 
It's taken me about 2 years (in my spare time), but I finally have some full-featured code based on the above app notes, code snippets on the internet and debugging with a scope.  It is used for an application where 3 QG8's, 1 QE128, and 1 24AA256SN Flash memory are all on the same bus (1 master, 3 slaves, 1 master & slave).  It uses an interrupt-driven approach, the master can transmit/receive data while continuing to process other work, an application can be a master and then turn around and act as a slave for another processor.  Code supports using program variables directly as buffers, or seperate buffers can be used.  In my application, data is transmitted as words (vs bytes), but this can be changed. 
 
To save others some of this trouble I thought I would post these example master and slave projects:
 

Outcomes