Hi,
I am brand new to the Freescale product suite and Code Warrior. I have inherited a project and the associated device which is a amateur radio device. The device has several components, 1) MC9S08QG8CPBE, 2) A MCP3422 ADC and a KTM-s1201. At any rate, the MCU communicates with the ADC via I2C.
If someone would be so kind as to point me in the right direction to Freescale I2c primer, I would be most appreciative.
The I2C source code included with the project is dated 8/2008. This is pretty much a "down on the metal" type program. Does Freescale have an I2C library I may link to?
//===================================================================
// MC9RS08KA8 IIC Subroutines 8/24/2008
// Written by John H. Fisher - K5JHF
//===================================================================
#include "derivative.h"
#include "iic.h"
//===================================================================
void i2c_send ( char send ) {
IICD = send; // master transmit;
while (!IICS_IICIF); // wait until IBIF;
IICS_IICIF = 1; // clear the interrupt event flag;
}
//===================================================================
Thanks,
73,
Ron / W4MMP
Hello Ronald,
I am attaching to this response a CodeWarrior v6.3 project which includes an IIC driver on MC9S08QG8 device, implementing state machines. In order to get the Acknowledge, you must ensure that the address configured on the driver matches with the address of the device.
One common mistake with this is that the address is a 7-bit value, which must be written on IICA register aligned to the left (consult section 11.3.1 on MC9S08QG8 Datasheet), because the LSB is the R/W bit. You must ensure the address alignment according with the value shown on IIC slave´s manufacturer datasheet.
I hope this material will be useful for you.
Have a great day. :smileyhappy:
David