This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

tms320f28069m: I2C EEPROM Example Code from C2000Ware: Example_2806xI2C_eeprom.c

Part Number: TMS320F28069M
Other Parts Discussed in Thread: DRV8301, TMS320F28069M, C2000WARE

I have successfully added an EEPROM to my DRV8301 board and can write and read to the EEPROM with the Example_2806xI2C_eeprom.c example code with the TMS320F28069M processor. I am able to write 1 or 2 bytes, but not more. This is the problem. I want to be able to write up to 4 bytes at at time. I added the additional bytes to the I2cMsgOut1 message and changed NumOfBytes to 4, and.... nothing. The bus sends out the address, the chip ACK's, and then silence on the bus. In addition, the interrupt i2c_int1a_isr stops going off all together.

Any ideas what may be going wrong?

Thanks!

  • Hi Charlie,

    Try these routines out:

    //////////////////////////
    // Write data to EEPROM //
    //////////////////////////
    //I2C_SLAVE_ADDR = 0x50 address of the EEPROM
    //I am writing 'h','e','l','l','o' to the EEPROM and then read it back later
    //I2C_NUMBYTES = 5
    //[MemoryHighAddr:MemoryLowAddr] -Address within the eeprom where you want to read/write
    //Data[] has the word 'hello' and RxdData[] will store data read from the eeprom
       I2caRegs.I2CSAR = I2C_SLAVE_ADDR; 			//Set slave address
       I2caRegs.I2CCNT = I2C_NUMBYTES + 2; 			//Set count to 5 characters plus 2 address bytes
       I2caRegs.I2CDXR = MemoryHighAddr;			//Send eeprom high address            
       I2caRegs.I2CMDR.bit.TRX = 1; 				//Set to Transmit mode
       I2caRegs.I2CMDR.bit.MST = 1; 				//Set to Master mode
       I2caRegs.I2CMDR.bit.FREE = 1;				//Run in FREE mode
       I2caRegs.I2CMDR.bit.STP = 1; 				//Stop when internal counter becomes 0
       I2caRegs.I2CMDR.bit.STT = 1; 				//Send the start bit, transmission will follow
       while(I2caRegs.I2CSTR.bit.XRDY == 0){}; 		//Do nothing till data is shifted out
       I2caRegs.I2CDXR = MemoryLowAddr;  			//Send eeprom low address
       
       for(i = 0; i < I2C_NUMBYTES; i++){
       	while(I2caRegs.I2CSTR.bit.XRDY == 0){}; 	//Do nothing till data is shifted out
       	I2caRegs.I2CDXR = Data[i]; 					//Send out the message
       } 
    //////////////////////////
    // Read data from EEPROM//
    //////////////////////////
       I2caRegs.I2CSAR = I2C_SLAVE_ADDR; 			//Set slave address
       I2caRegs.I2CCNT = 2; 						//Set count to 2 address bytes
       I2caRegs.I2CDXR = MemoryHighAddr;			//Send eeprom high address            
       I2caRegs.I2CMDR.bit.TRX = 1; 				//Set to Transmit mode
       I2caRegs.I2CMDR.bit.MST = 1; 				//Set to Master mode
       I2caRegs.I2CMDR.bit.FREE = 1;				//Run in FREE mode
       I2caRegs.I2CMDR.bit.STP = 0; 				//Dont release the bus after Tx
       I2caRegs.I2CMDR.bit.STT = 1; 				//Send the start bit, transmission will follow
       
       while(I2caRegs.I2CSTR.bit.XRDY == 0){}; 		//Do nothing till data is shifted out
       I2caRegs.I2CDXR = MemoryLowAddr; 			//Send eeprom low address
       I2caRegs.I2CCNT = I2C_NUMBYTES;				//read 5 bytes from eeprom
       I2caRegs.I2CMDR.bit.TRX = 0; 				//Set to Recieve mode
       I2caRegs.I2CMDR.bit.MST = 1; 				//Set to Master mode
       I2caRegs.I2CMDR.bit.FREE = 1;				//Run in FREE mode
       I2caRegs.I2CMDR.bit.STP = 1; 				//Stop when internal counter becomes 0
       I2caRegs.I2CMDR.bit.STT = 1; //Repeated start, Reception will follow
       for(i = 0; i < I2C_NUMBYTES; i++){
       	while(I2caRegs.I2CSTR.bit.RRDY == 0){}; 	//I2CDRR not ready to read?
       	RxdData[i] = I2caRegs.I2CDRR;
       }

    Regards,

    Gautam

  • Hi Gautam,

    Thank you very much for your code example. Attached is the example code I'm having problems with. Can you take a look at it and understand why I cannot send / receive more than 2 bytes?

    Much thanks.

    Charlie

    //###########################################################################
    //
    // FILE:   Example_2806xI2C_eeprom.c
    //
    // TITLE:  I2C EEPROM Example
    //
    //!  \addtogroup f2806x_example_list
    //!  <h1>I2C EEPROM(i2c_eeprom)</h1>
    //!
    //!  This program requires an external I2C EEPROM connected to
    //!  the I2C bus at address 0x50.
    //!  This program will write 1-14 words to EEPROM and read them back.
    //!  The data written and the EEPROM address written to are contained
    //!  in the message structure, \b I2cMsgOut1. The data read back will be
    //!  contained in the message structure \b I2cMsgIn1.
    //!  
    //!  \note This program will only work on kits that have an on-board I2C EEPROM. 
    //!
    //!  \b Watch \b Variables \n
    //!  - I2cMsgIn1
    //!  - I2cMsgOut1
    //
    //###########################################################################
    // $TI Release: F2806x Support Library v2.02.00.00 $
    // $Release Date: Thu Dec  7 18:50:05 CST 2017 $
    // $Copyright:
    // Copyright (C) 2009-2017 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without 
    // modification, are permitted provided that the following conditions 
    // are met:
    // 
    //   Redistributions of source code must retain the above copyright 
    //   notice, this list of conditions and the following disclaimer.
    // 
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the 
    //   documentation and/or other materials provided with the   
    //   distribution.
    // 
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    // 
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //###########################################################################
    
    //
    // Included Files
    //
    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    //#include "F2806x_I2C_defines.h"
    //
    // Note: I2C Macros used in this example can be found in the
    // F2806x_I2C_defines.h file
    //
    
    //
    // Function Prototypes
    //
    void   I2CA_Init(void);
    Uint16 I2CA_WriteData(struct I2CMSG *msg);
    Uint16 I2CA_ReadData(struct I2CMSG *msg);
    __interrupt void i2c_int1a_isr(void);
    void pass(void);
    void fail(void);
    
    //
    // Defines
    //
    #define I2C_SLAVE_ADDR        0x50 //=0x1010000 (7-bit address, so when the chip address is shifted, 0xA0, or 0b1010000, looks like 0b01010000, or 0x50)
    #define I2C_NUMBYTES          2
    #define I2C_EEPROM_HIGH_ADDR  0x00
    #define I2C_EEPROM_LOW_ADDR   0x30
    //#define I2C_EEPROM_LOW_ADDR   0x00
    
    //
    // Globals
    //
    // Two bytes will be used for the outgoing address,
    // thus only setup 14 bytes maximum
    //
    struct I2CMSG I2cMsgOut1={I2C_MSGSTAT_SEND_WITHSTOP,
                              I2C_SLAVE_ADDR,
                              I2C_NUMBYTES,
                              I2C_EEPROM_HIGH_ADDR,
                              I2C_EEPROM_LOW_ADDR,
                              0x08,                   // Msg Byte 1
                              0x34,                   // Msg Byte 2
                              0x17,                   // Msg Byte 3
                              0x04};                  // Msg Byte 4
    
    struct I2CMSG I2cMsgIn1={ I2C_MSGSTAT_SEND_NOSTOP,
                              I2C_SLAVE_ADDR,
                              I2C_NUMBYTES,
                              I2C_EEPROM_HIGH_ADDR,
                              I2C_EEPROM_LOW_ADDR};
    
    struct I2CMSG *CurrentMsgPtr;				// Used in interrupts
    Uint16 PassCount;
    Uint16 FailCount;
    
    //
    // Main
    //
    void main(void)
    {
        Uint16 Error;
        Uint16 i;
    
        CurrentMsgPtr = &I2cMsgOut1;
    
        //
        // Step 1. Initialize System Control:
        // PLL, WatchDog, enable Peripheral Clocks
        // This example function is found in the F2806x_SysCtrl.c file.
        //
        InitSysCtrl();
    
        //
        // Step 2. Initalize GPIO:
        // This example function is found in the F2806x_Gpio.c file and
        // illustrates how to set the GPIO to it's default state.
        //
        //InitGpio();
        
        //
        // Setup only the GP I/O only for I2C functionality
        //
        InitI2CGpio();
    
        //
        // Step 3. Clear all interrupts and initialize PIE vector table:
        // Disable CPU interrupts
        //
        DINT;
    
        //
        // Initialize PIE control registers to their default state.
        // The default state is all PIE interrupts disabled and flags
        // are cleared.
        // This function is found in the F2806x_PieCtrl.c file.
        //
        InitPieCtrl();
    
        //
        // Disable CPU interrupts and clear all CPU interrupt flags
        //
        IER = 0x0000;
        IFR = 0x0000;
    
        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        // This will populate the entire table, even if the interrupt
        // is not used in this example.  This is useful for debug purposes.
        // The shell ISR routines are found in F2806x_DefaultIsr.c.
        // This function is found in F2806x_PieVect.c.
        //
        InitPieVectTable();
    
        //
        // Interrupts that are used in this example are re-mapped to
        // ISR functions found within this file.
        //
        EALLOW;	// This is needed to write to EALLOW protected registers
        PieVectTable.I2CINT1A = &i2c_int1a_isr;
        EDIS;   // This is needed to disable write to EALLOW protected registers
    
        //
        // Step 4. Initialize all the Device Peripherals:
        // This function is found in F2806x_InitPeripherals.c
        //
        //InitPeripherals(); // Not required for this example
        I2CA_Init();
    
        //
        // Step 5. User specific code
        //
        
        //
        // Clear Counters
        //
        PassCount = 0;
        FailCount = 0;
    
        //
        // Clear incoming message buffer
        //
        for (i = 0; i < I2C_MAX_BUFFER_SIZE; i++)
        {
            I2cMsgIn1.MsgBuffer[i] = 0x0000;
        }
    
        //
        // Enable interrupts required for this example
        //
    
        //
        // Enable I2C interrupt 1 in the PIE: Group 8 interrupt 1
        //
        PieCtrlRegs.PIEIER8.bit.INTx1 = 1;
    
        //
        // Enable CPU INT8 which is connected to PIE group 8
        //
        IER |= M_INT8;
        EINT;
    
        //
        // Application loop
        //
        for(;;)
        {
            //
            // Write data to EEPROM section
            //
            //
            // Check the outgoing message to see if it should be sent.
            // In this example it is initialized to send with a stop bit.
            //
            if(I2cMsgOut1.MsgStatus == I2C_MSGSTAT_SEND_WITHSTOP)
            {
                Error = I2CA_WriteData(&I2cMsgOut1);
                
                //
                // If communication is correctly initiated, set msg status to busy
                // and update CurrentMsgPtr for the interrupt service routine.
                // Otherwise, do nothing and try again next loop. Once message is
                // initiated, the I2C interrupts will handle the rest. Search for
                // i2c_int1a_isr in this file.
                //
                if (Error == I2C_SUCCESS)
                {
                    CurrentMsgPtr = &I2cMsgOut1;
                    I2cMsgOut1.MsgStatus = I2C_MSGSTAT_WRITE_BUSY;
                }
            }
    
            //
            // Read data from EEPROM section
            //
    
            //
            // Check outgoing message status. Bypass read section if status is
            // not inactive.
            //
            if (I2cMsgOut1.MsgStatus == I2C_MSGSTAT_INACTIVE)
            {
                //
                // Check incoming message status.
                //
                if(I2cMsgIn1.MsgStatus == I2C_MSGSTAT_SEND_NOSTOP)
                {
                    //
                    // EEPROM address setup portion
                    //
                    while(I2CA_ReadData(&I2cMsgIn1) != I2C_SUCCESS)
                    {
                        //
                        // Maybe setup an attempt counter to break an infinite 
                        // while loop. The EEPROM will send back a NACK while it is
                        // performing a write operation. Even though the write 
                        // communique is complete at this point, the EEPROM could 
                        // still be busy programming the data. Therefore, multiple 
                        // attempts are necessary.
                        //
                    }
                    
                    //
                    // Update current message pointer and message status
                    //
                    CurrentMsgPtr = &I2cMsgIn1;
                    I2cMsgIn1.MsgStatus = I2C_MSGSTAT_SEND_NOSTOP_BUSY;
                }
    
                //
                // Once message has progressed past setting up the internal address
                // of the EEPROM, send a restart to read the data bytes from the
                // EEPROM. Complete the communique with a stop bit. MsgStatus is
                // updated in the interrupt service routine.
                //
                else if(I2cMsgIn1.MsgStatus == I2C_MSGSTAT_RESTART)
                {
                    //
                    // Read data portion
                    //
                    while(I2CA_ReadData(&I2cMsgIn1) != I2C_SUCCESS)
                    {
                        //
                        // Maybe setup an attempt counter to break an infinite 
                        // while loop.
                        //
                    }
                    
                    //
                    // Update current message pointer and message status
                    //
                    CurrentMsgPtr = &I2cMsgIn1;
                    I2cMsgIn1.MsgStatus = I2C_MSGSTAT_READ_BUSY;
                }
            }
        }
    }
    
    //
    // I2CA_Init - 
    //
    void
    I2CA_Init(void)
    {
        //
        // Initialize I2C
        //
        I2caRegs.I2CSAR = 0x0050;     // Slave address - EEPROM control code
    
        I2caRegs.I2CPSC.all = 6;		// Prescaler - need 7-12 Mhz on module clk
        I2caRegs.I2CCLKL = 10;			// NOTE: must be non zero
        I2caRegs.I2CCLKH = 5;			// NOTE: must be non zero
        I2caRegs.I2CIER.all = 0x24;		// Enable SCD & ARDY interrupts
    
        //
        // Take I2C out of reset. Stop I2C when suspended
        //
        I2caRegs.I2CMDR.all = 0x0020;	
    
        I2caRegs.I2CFFTX.all = 0x6000;	// Enable FIFO mode and TXFIFO
        I2caRegs.I2CFFRX.all = 0x2040;	// Enable RXFIFO, clear RXFFINT,
    
        return;
    }
    
    //
    // I2CA_WriteData - 
    //
    Uint16
    I2CA_WriteData(struct I2CMSG *msg)
    {
        Uint16 i;
    
        //
        // Wait until the STP bit is cleared from any previous master communication.
        // Clearing of this bit by the module is delayed until after the SCD bit is
        // set. If this bit is not checked prior to initiating a new message, the
        // I2C could get confused.
        //
        if (I2caRegs.I2CMDR.bit.STP == 1)
        {
            return I2C_STP_NOT_READY_ERROR;
        }
    
        //
        // Setup slave address
        //
        I2caRegs.I2CSAR = msg->SlaveAddress;
    
        //
        // Check if bus busy
        //
        if (I2caRegs.I2CSTR.bit.BB == 1)
        {
            return I2C_BUS_BUSY_ERROR;
        }
    
        //
        // Setup number of bytes to send MsgBuffer + Address
        //
        I2caRegs.I2CCNT = msg->NumOfBytes+2;
    
        //
        // Setup data to send
        //
        I2caRegs.I2CDXR = msg->MemoryHighAddr;
        I2caRegs.I2CDXR = msg->MemoryLowAddr;
        
        // for (i=0; i<msg->NumOfBytes-2; i++)
        for (i=0; i<msg->NumOfBytes; i++)
        {
            I2caRegs.I2CDXR = *(msg->MsgBuffer+i);
        }
    
        //
        // Send start as master transmitter
        //
        I2caRegs.I2CMDR.all = 0x6E20;
    
        return I2C_SUCCESS;
    }
    
    //
    // I2CA_ReadData - 
    //
    Uint16
    I2CA_ReadData(struct I2CMSG *msg)
    {
        //
        // Wait until the STP bit is cleared from any previous master communication.
        // Clearing of this bit by the module is delayed until after the SCD bit is
        // set. If this bit is not checked prior to initiating a new message, the
        // I2C could get confused.
        //
        if (I2caRegs.I2CMDR.bit.STP == 1)
        {
            return I2C_STP_NOT_READY_ERROR;
        }
    
        I2caRegs.I2CSAR = msg->SlaveAddress;
    
        if(msg->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP)
        {
            //
            // Check if bus busy
            //
            if (I2caRegs.I2CSTR.bit.BB == 1)
            {
                return I2C_BUS_BUSY_ERROR;
            }
            I2caRegs.I2CCNT = 2;
            I2caRegs.I2CDXR = msg->MemoryHighAddr;
            I2caRegs.I2CDXR = msg->MemoryLowAddr;
    
            //
            // Send data to setup EEPROM address
            //
            I2caRegs.I2CMDR.all = 0x2620;
        }
    
        else if(msg->MsgStatus == I2C_MSGSTAT_RESTART)
        {
            I2caRegs.I2CCNT = msg->NumOfBytes;	// Setup how many bytes to expect
            I2caRegs.I2CMDR.all = 0x2C20;       // Send restart as master receiver
        }
    
        return I2C_SUCCESS;
    }
    
    //
    // i2c_int1a_isr - I2C-A
    //
    __interrupt void
    i2c_int1a_isr(void)
    {
        Uint16 IntSource, i;
    
        //
        // Read interrupt source
        //
        IntSource = I2caRegs.I2CISRC.all;
    
        //
        // Interrupt source = stop condition detected
        //
        if(IntSource == I2C_SCD_ISRC)
        {
            //
            // If completed message was writing data, reset msg to inactive state
            //
            if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_WRITE_BUSY)
            {
                CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_INACTIVE;
            }
            else
            {
                //
                // If a message receives a NACK during the address setup portion 
                // of the EEPROM read, the code further below included in the 
                // register access ready interrupt source code will generate a stop
                // condition. After the stop condition is received (here), set the 
                // message status to try again. User may want to limit the number 
                // of retries before generating an error.
                //
                if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
                {
                    CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_SEND_NOSTOP;
                }
                
                //
                // If completed message was reading EEPROM data, reset msg to 
                // inactive state and read data from FIFO.
                //
                else if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_READ_BUSY)
                {
                    CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_INACTIVE;
                    for(i=0; i < I2C_NUMBYTES; i++)
                    {
                        CurrentMsgPtr->MsgBuffer[i] = I2caRegs.I2CDRR;
                    }
                    
                    //
                    // Check received data
                    //
                    for(i=0; i < I2C_NUMBYTES; i++)
                    {
                        if(I2cMsgIn1.MsgBuffer[i] == I2cMsgOut1.MsgBuffer[i])
                        {
                            PassCount++;
                        }
                        else
                        {
                            FailCount++;
                        }
                    }
                    
                    if(PassCount == I2C_NUMBYTES)
                    {
                        pass();
                    }
                    else
                    {
                        fail();
                    }
                }
            }
        }
    
        //
        // Interrupt source = Register Access Ready
        // This interrupt is used to determine when the EEPROM address setup 
        // portion of the read data communication is complete. Since no stop bit is 
        // commanded, this flag tells us when the message has been sent instead of 
        // the SCD flag. If a NACK is received, clear the NACK bit and command a 
        // stop. Otherwise, move on to the read data portion of the communication.
        //
        else if(IntSource == I2C_ARDY_ISRC)
        {
            if(I2caRegs.I2CSTR.bit.NACK == 1)
            {
                I2caRegs.I2CMDR.bit.STP = 1;
                I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT;
            }
            else if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
            {
                CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_RESTART;
            }
        }
    
        else
        {
            //
            // Generate some error due to invalid interrupt source
            //
            __asm("   ESTOP0");
        }
    
        //
        // Enable future I2C (PIE Group 8) interrupts
        //
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
    }
    
    //
    // pass -
    //
    void
    pass()
    {
        __asm("   ESTOP0");
        for(;;);
    }
    
    //
    // fail - 
    //
    void
    fail(void)
    {
        __asm("   ESTOP0");
        for(;;);
    }
    
    //
    // End of File
    //
    
    

  • Hey there Charlie,

    Are you still facing this issue? If so, please provide some follow up and let me know what specific questions you have. If not, please post what you did to resolve your issue.

    Have you monitored the bus with a scope? do you see the ACK coming across?

    Thanks,
    Mark
  • Hi Mark,
    No, my issue is not yet resolved.

    I'm using your example code from C2000Ware for I2C communication with a EEPROM (Example_2806xI2C_eeprom.c, attached earlier in this string.) It is the code I'm having problems with, not hardware.

    The problem is that I can only set the code to write 2 bytes, and it should be able to write up to 14 bytes at one time. A 1 byte write works, a 2 byte write works, but 3 and 4 byte writes do not work. I have not tried higher than 4 bytes.

    When set to 3 or 4, the interrupt no longer goes off. If I disable the write part of the code, the read part works fine; the interrupt goes off, and it reads 4 bytes from the EEPROM

    Any help is greatly appreciated!
    Charlie
  • Hi Mark,

    Have you had a chance to look at this code or talk with the engineer that wrote it? Any help is greatly appreciated!

    Charlie

  • Hi Charlie, sorry for the delay again.

    The person who wrote this software is no longer with the company. It was created a long time ago.

    The Max FIFO depth for this module is 4 bytes, not 14. Maybe this is a type?

    It seems like you have not updated your #I2C_NUMBYTES to be 4. (line 83).
    If you update the #I2C_NUMBytes, your for loop in the Write data should write the correct number of words. It looks like you set up the I2CCNT register to be 4 in lin 379, but then only traverse through 2 bytes in the for loop (line 388). The I2C will still be waiting for additional data words but never be able to load them again since there is no way to re-enter WriteData until the last word completes.

    I hope this helps.
    Mark
  • Hi Mark,

    If I set I2C_NUMBYTES to 4, the interrupt no longer goes off. This is fundamentally what I do not understand.

    Thank you for following up on this issue.

    Charlie

  • Charlie,

    I will have some time to look into this again tomorrow (Friday)

    -Mark
  • Charlie,

    I was unable to resolve this today. I'll take a look on Monday.

    Thanks,
    Mark
  • I suspect that's what's happening is that in the write data function you're setting the I2CCNT register to 6 (I2C_NUMBYTES+2) and then trying to write 6 bytes to the FIFO, but since the FIFO is only big enough for 4, the extras get dropped. The I2C only sends 4 bytes and so it keeps waiting for the rest of the bytes (I2CCNT bytes) before sending the stop condition--the stop condition that triggers the interrupt.

    You need to adjust the code so that it does not overflow the TX FIFO.

    Whitney
  • So, the TX FIFO is 4 bytes, and that has to hold the address high and low bytes, so there are only two bytes left for data?

  • That is correct.
  • Thank you very much for getting this issue resolved. I really appreciate the great support.

    Charlie