Hi,
I ma facing issue for I2C interrupt not getting hit even after initializing the registers. Even the initialization to F0 does not get set initially.
Since I am transferring multiple data at a time later It gets set to FO
Snippet in main file:
I2C initialization
/* Initialize the I2C Module. */
_IIC1A.IIC1AData = 0x02; /* Set the master address to be 1 */
_IIC1F.IIC1FData = 0x06; for Bus frequency of 6.75MHZ
YYY[][] AND XXX[][] are initialized to set of values and then initialized as below
/* configure 1 */
for (i = 0; i < YY; i++)
{
SendI2CData(&YYY[i][0]);
for (j = 0; j < XX; j++)
{
SendI2CData(&XXX[j][0]);
/* Initialize ourselves as the master by setting IICEN, IICIE, MST and TX. **
/*within SendI2CData*/
_IIC1C1.IIC1CData = 0xf0;
Snippet for interrupt
__interrupt void __near _Iic_Isr(void) {
/* Declarations and Initializations. */
volatile Uint8 DummyRead;
/* Statements. */
/* Clear the Interrupt Pending flag. */
_IIC1S.Bit.iicif = true;
/* Check the mode of operation; are we master. */
if (_IIC1C1.Bit.mst) {
/* We in Transmit mode. */
if (_IIC1C1.Bit.tx) {
/* Have all the bytes
Have you tried setting the IICEN, MST, TX bits within your IIC initialize routine (which is where I would put it anyway), and just set the IICIE bit within your SendI2CData() function?
Are you certain that your slave/target device is connected and able to generate the ACK bit on the end of the transfer?
Also, are your linker file, and interrupt vector source files setup to put the address of your IIC_ISR() function at the IIC1 vector address location at flash memory location 0xFFC6:FFC7? The address of your ISR must be loaded at the proper vector table location to be called when the IIC1 interrupt occurs.
Hi Michael,
I will explain clearly what I am observing
So after initializing IIC1A,IIC1f,IIC1C1 to desired values. When trying to set in SendI2CData() the IIC1C1 to 0xF0,it takes 0xD0 and it shows IIC1S as 0x92.After this its goes to IIC ISR but it does not transfer since the master bit is not set. Again SendI2CData() is called to transfer the next set of data, this time it sets IIC1C1 to 0xF0,IIC1S shows 0x80 but it does not enter the IIC ISR routine again
At the moment I am not sure what might cause the behavior you describe - the master mode bit should remain set if you are setting it. Maybe try to set the master bit first in the initialization routine, then OR in the enable bit and set that too? I have seen some peripherals on some micros not initialize properly depending on the sequence of configuration bits, but I have not seen this behavior with this series (9S08AC) of devices.
I think there is some I2C register settings issue with HCSO8 . I checked whether the SCL and SDA line connected to different units were connected and it shows all are connected..
Something is not making the bits to set even though it is R/W register
This does appear to be a bit odd. I've used I2C on many microcontrollers before, but my recent project (involving (2) MC9S08AC60) used SPI interface instead due to legacy requirements, so I don't have ready code on hand for I2C to share that I know for certain is working on MC9S08AC chips.
Have you looked at this I2C application note for any clues?
http://www.nxp.com/assets/documents/data/en/application-notes/AN3291.pdf
Have you made any progress?
Yes Michael,
it behaves weird .I had done some combinations to make that it set and it was working yesterday by getting the bit to set . But today with same code it is behaving again like that .Any suggestions to avoid this
I am setting 0xf0 in IIC1C1 register and it is setting as 0xd0
Thanks Michael for the reply
Yes the interrupt is placed at FFC6 location as per the project prm file
The problem I am facing is .mst bit is not getting set and it shows IIC1S that there is an arbitration loss bit getting set
If I am giving 0xFO it is taking as 0xD0
I am initializing 0xf0 in IIC1C register and it is setting as 0xd0