video_man

HCS08GB I2C Help

Discussion created by video_man on Sep 18, 2006
Latest reply on Oct 19, 2007 by bigmac
1. Is it true the IIC module must be disabled and then enabled for every I2C Master write sequence? I don't see this documented in the MC9S08GB/GT Data Sheet, but it's in the code of the HCS08 Peripheral Module Quick Reference (below). Indeed if I don't disable the IIC module in the function below after the first write, I don't seem to get another I2C Master write.

2. Is the time delay after the START signal in write function below for the uP operation, or the receiver's benefit?

3. I'm having intermittent operation with back to back Master write sequences. Is there a need for some time delay between sending a STOP signal and writing the next byte to the IIC data register? Signal quality appears ok on the board, but the uP sometimes just stops sending during a series of Master write sequences. I'm using the IRQ handler from the HCS08QRUG.pdf.

4. Any HCS08 IIC programming tips would be welcome!

From HCS08QRUG.pdf:

unsigned char WriteBytesI2C (unsigned char slaveAddress,unsigned char numberOfBytes){

[cut]

IICC_IICEN = 0; // --- disable IIC module
IICC_IICEN = 1; // --- enable IIC module
IICS;
IICS_IICF=1;
IICC_MST = 0;
IICS_SRW=0;
IICC_TX = 1;
IICC_MST = 1; // Send Start Bit
for(Temp=0;Temp5;Temp++); // Small delay
ICD=slaveAddress; // Send slave address
return(1);
}

Outcomes