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.

SM470R1B1M-HT: I2C Module not working

Part Number: SM470R1B1M-HT

hello,

I am trying to read/write an I2C memory.

I have tried to initialize the I2C2 module and to send one byte for testing. I cannot see anything on SCL and SDA pins. I have other modules (SCI, ADC) working w/o problems.

I am using a 8MHz oscillator with M=4 and R=2 for a 32MHz SYSCLK and 16MHz ICLK.

Any help will be appreciated.

Thanks,

Marius

  • Hi,

      Sorry, I don't have much experience with SM470R1B1M-HT in particular as this is a rather old device that I never worked on before. However, in general, for I2C to work, you must have external pullup resistor on the bus. Can you confirm this is the case? 

     To help troubleshooting, do you have the same issue on other I2C (e.g. I2C1, I2C3 and others). If you are having issue on all I2Cx, then it is most likely related to your software. 

  • Hi Charles,

    Yes, I have pull-up resistors.

    Yes, I suppose there is a problem in initializing the I2C module. Unfortunately, there is no example on TI website.  

    Regards,

    Marius 

  • Hi Marius,

      Unfortunately, there is no example. I will suggest you view the register window for I2C2 in CCS and make sure all the settings are correct. One quick thing to check is that the SCL and SDA pins are in their functional mode, not in GPIO mode. As a matter of fact, I will even suggest you first enable the pins in GPIO mode first just to make sure you can toggle these pins before you change them to functional mode. 

      There is some similarity between SM470 and TMS570 for the I2C module. For TMS570 I2C module, I find the below example to access a PF8570 RAM.

    /* Include Files */
    
    #include "sys_common.h"
    
    /* USER CODE BEGIN (1) */
    #include "i2c.h"
    /* USER CODE END */
    
    /** @fn void main(void)
    *   @brief Application main function
    *   @note This function is empty by default.
    *
    *   This function is called after startup.
    *   The user can use this function to implement the application.
    */
    
    /* USER CODE BEGIN (2) */
    #define DATA_COUNT  10
    
    #define Master_Address 0x26
    #define Slave_Address  0x8
    #define Slave_Word_address 0x00
    #define Receive_data_setup 0x1 // 1 Word address
    
    uint8_t TX_Data_Master[DATA_COUNT] = {0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19};
    uint8_t RX_Data_Master[DATA_COUNT] = { 0 };
    
    uint8_t TX_Data_Slave[10] = { 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29};
    uint8_t RX_Data_Slave[10] = { 0 };
    
    #define PCF8570_ADDRESS   0x57 // All A0,A1,A2 are tied to 3.3V in PCF8570
    uint32_t temp1, temp2;
    
    /* USER CODE END */
    
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    
    	int repeat = 0; int delay =0;
    
    	/* I2C Init as per GUI
    	 *  Mode = Master - Transmitter
    	 *  baud rate = 100KHz
    	 *  Count = 10
    	 *  Bit Count = 8bit
    	 */
    	i2cInit();
    
    ///////////////////////////////////////////////////////////////
    //        Master Transfer Functionality                      //
    ///////////////////////////////////////////////////////////////
    
    	/* Configure address of Slave to talk to */
    	i2cSetSlaveAdd(i2cREG1, PCF8570_ADDRESS);
    
    	/* Set direction to Transmitter */
    	/* Note: Optional - It is done in Init */
    	i2cSetDirection(i2cREG1, I2C_TRANSMITTER);
    
    	/* Configure Data count */
    	/* Data Count + 1 ( Word Address) */
    	i2cSetCount(i2cREG1, DATA_COUNT + 1);
    
    	/* Set mode as Master */
    	i2cSetMode(i2cREG1, I2C_MASTER);
    
    	/* Set Stop after programmed Count */
    	i2cSetStop(i2cREG1);
    
    	/* Transmit Start Condition */
    	i2cSetStart(i2cREG1);
    
    	/* Send the Word Address */
    	i2cSendByte(i2cREG1, Slave_Word_address);
    
    	/* Tranmit DATA_COUNT number of data in Polling mode */
    	i2cSend(i2cREG1, DATA_COUNT, TX_Data_Master);
    
    	/* Wait until Bus Busy is cleared */
    	while(i2cIsBusBusy(i2cREG1) == true);
    
    	/* Wait until Stop is detected */
    	while(i2cIsStopDetected(i2cREG1) == 0);
    
    	/* Clear the Stop condition */
    	i2cClearSCD(i2cREG1);
    
    	/* Simple Dealya before starting Next Block */
    	/* Depends on how quick the Slave gets ready */
    	for(delay=0;delay<100000;delay++);
    
    
    	///////////////////////////////////////////////////////////////
    	//        Master Receive Functionality                      //
    	///////////////////////////////////////////////////////////////
    
    	/*****************************************/
    	//// Setup Slave to receving the data
    	/*****************************************/
    
    	/* wait until MST bit gets cleared, this takes
    	 * few cycles after Bus Busy is cleared */
    	while(i2cIsMasterReady(i2cREG1) != true);
    
    	/* Configure address of Slave to talk to */
    	i2cSetSlaveAdd(i2cREG1, PCF8570_ADDRESS);
    
    	/* Set direction to Transmitter */
    	/* Note: Optional - It is done in Init */
    	i2cSetDirection(i2cREG1, I2C_TRANSMITTER);
    
    	/* Configure Data count */
    	/* Slave address + Word address write operation before reading */
    	i2cSetCount(i2cREG1, Receive_data_setup);
    
    	/* Set mode as Master */
    	i2cSetMode(i2cREG1, I2C_MASTER);
    
    	/* Set Stop after programmed Count */
    	i2cSetStop(i2cREG1);
    
    	/* Transmit Start Condition */
    	i2cSetStart(i2cREG1);
    
    	/* Send the Word Address */
    	i2cSendByte(i2cREG1, Slave_Word_address);
    
    	/* Wait until Bus Busy is cleared */
    	while(i2cIsBusBusy(i2cREG1) == true);
    
    	/* Wait until Stop is detected */
    	while(i2cIsStopDetected(i2cREG1) == 0);
    
    	/* Clear the Stop condition */
    	i2cClearSCD(i2cREG1);
    
    	/*****************************************/
    	//// Start receving the data From Slave
    	/*****************************************/
    
    	/* wait until MST bit gets cleared, this takes
    	 * few cycles after Bus Busy is cleared */
    	while(i2cIsMasterReady(i2cREG1) != true);
    
    	/* Configure address of Slave to talk to */
    	i2cSetSlaveAdd(i2cREG1, PCF8570_ADDRESS);
    
    	/* Set direction to receiver */
    	i2cSetDirection(i2cREG1, I2C_RECEIVER);
    
    	/* Configure Data count */
    	/* Note: Optional - It is done in Init, unless user want to change */
    	i2cSetCount(i2cREG1, DATA_COUNT);
    
    	/* Set mode as Master */
    	i2cSetMode(i2cREG1, I2C_MASTER);
    
    	/* Set Stop after programmed Count */
    	i2cSetStop(i2cREG1);
    
    	/* Transmit Start Condition */
    	i2cSetStart(i2cREG1);
    
    	/* Tranmit DATA_COUNT number of data in Polling mode */
    	i2cReceive(i2cREG1, DATA_COUNT, RX_Data_Master);
    
    	/* Wait until Bus Busy is cleared */
    	while(i2cIsBusBusy(i2cREG1) == true);
    
    	/* Wait until Stop is detected */
    	while(i2cIsStopDetected(i2cREG1) == 0);
    
    	/* Clear the Stop condition */
    	i2cClearSCD(i2cREG1);
    
    	asm(" nop");
    	asm(" nop");
    	asm(" nop");
    
    	while(1);
    
    /* USER CODE END */
    }

      

  • Hi Tsai,

    Thanks for your response.

    You sent me the code but it doesn't include the i2cInit() function. I think my problem is caused by the initialization of the I2C module.

    Can you send me this function.

    Regards,

    Marius

  • Hi Marius,

      Here is the i2c.c driver file. 

    /** @file i2c.c 
    *   @brief I2C Driver Implementation File
    *   @date 29.May.2013
    *   @version 03.05.02
    *
    */
    
    /* (c) Texas Instruments 2009-2013, All rights reserved. */
    
    /* USER CODE BEGIN (0) */
    /* USER CODE END */
    
    #include "i2c.h"
    
    /* USER CODE BEGIN (1) */
    /* USER CODE END */
    
    /** @struct g_i2CTransfer
    *   @brief Interrupt mode globals
    *
    */
    static struct g_i2cTransfer
    {
        uint32  mode;
        uint32  length;
        uint8   * data;
    } g_i2cTransfer_t[2U];
    
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    
    /** @fn void i2cInit(void)
    *   @brief Initializes the i2c Driver
    *
    *   This function initializes the i2c module.
    */
    void i2cInit(void)
    {
    /* USER CODE BEGIN (3) */
    /* USER CODE END */
    
        /** @b initialize @b I2C */
    
        /** - i2c out of reset */
        i2cREG1->MDR = (1U << 5U);
    
        /** - set i2c mode */
        i2cREG1->MDR =   (0U << 15U)     /* nack mode                        */           
                       | (0U << 14U)     /* free running                      */           
                       |  0U     /* start condition - master mode only */    
                       | (1U <<11U)     /* stop condition                     */ 
                       | (1U <<10U)     /* Master/Slave mode                 */ 
                       | (I2C_TRANSMITTER)     /* Transmitter/receiver              */ 
                       | (I2C_10BIT_AMODE)     /* xpanded address                   */ 
                       | (0 << 7U)     /* repeat mode                       */ 
                       | (0U << 6U)     /* digital loopback                  */          
                       | (0U << 4U)     /* start byte - master only          */ 
                       | (0U)     /* free data format                  */ 
                       | (I2C_8_BIT);     /* bit count                         */ 
    
    
        /** - set i2c extended mode */
        i2cREG1->EMDR = (0U << 25U);
    
        /** - set i2c data count */
        i2cREG1->CNT = 16U;
    
        /** - disable all interrupts */
        i2cREG1->IMR = 0x00U;    
    
        /** - set prescale */
        i2cREG1->PSC = 10U;
    
        /** - set clock rate */
        i2cREG1->CLKH = 36U;
        i2cREG1->CLKL = 36U;
    
        /** - set i2c pins functional mode */
        i2cREG1->FUN = (0U);
    
        /** - set i2c pins default output value */
        i2cREG1->DOUT = (0U << 1U)     /* sda pin */
                      | (0U);     /* scl pin */
    
        /** - set i2c pins output direction */
        i2cREG1->DIR = (0U << 1U)     /* sda pin */
                     | (0U);     /* scl pin */
    
        /** - set i2c pins open drain enable */
        i2cREG1->ODR = (0U << 1U)     /* sda pin */
                     | (0U);     /* scl pin */
    
        /** - set i2c pins pullup/pulldown enable */
        i2cREG1->PD = (0U << 1U)     /* sda pin */
                    | (0U);     /* scl pin */
    
        /** - set i2c pins pullup/pulldown select */
        i2cREG1->PSL = (1U << 1U)     /* sda pin */
                     | (1U);     /* scl pin */
    
        /** - set interrupt enable */
        i2cREG1->IMR    = (0U << 6U)     /* Address as slave interrupt      */
                        | (0U << 5U)     /* Stop Condition detect interrupt */
                        | (0U << 4U)     /* Transmit data ready interrupt   */
                        | (0U << 3U)     /* Receive data ready interrupt    */
                        | (0U << 2U)     /* Register Access ready interrupt */
                        | (0U << 1U)     /* No Acknowledgment interrupt    */
                        | (0U);     /* Arbitration Lost interrupt      */
        
        i2cREG1->MDR |= I2C_RESET_OUT; /* i2c out of reset */ 
    	
    	/** - initialize global transfer variables */
        g_i2cTransfer_t[0U].mode   = 0U << 8U;
        g_i2cTransfer_t[0U].length = 0U;
    
    /* USER CODE BEGIN (4) */
    /* USER CODE END */
    
    }
    
    /** @fn void i2cSetOwnAdd(i2cBASE_t *i2c, uint32 oadd)
    *   @brief Set I2C Own Address
    *   @param[in] oadd - I2C Own address (7-bit or 10 -bit address)
    *   @param[in] i2c  - i2c module base address
    *   Set the Own address of the I2C module.
    */
    void i2cSetOwnAdd(i2cBASE_t *i2c, uint32 oadd)
    {
        i2cREG1->OAR = oadd;  /* set own address */
    }
    
    /** @fn void i2cSetSlaveAdd(i2cBASE_t *i2c, uint32 sadd)
    *   @brief Set Port Direction
    *   @param[in] sadd - I2C Slave address
    *   @param[in] i2c  - i2c module base address
    *   Set the Slave address to communicate which is must in Master mode.
    */
    void i2cSetSlaveAdd(i2cBASE_t *i2c, uint32 sadd)
    {
        i2cREG1->SAR = sadd;  /* set slave address */
    }
    
    /** @fn void i2cSetBaudrate(i2cBASE_t *i2c, uint32 baud)
    *   @brief Change baudrate at runtime.
    *   @param[in] i2c  - i2c module base address
    *   @param[in] baud - baudrate in KHz
    *
    *   Change the i2c baudrate at runtime.
    */
    void i2cSetBaudrate(i2cBASE_t *i2c, uint32 baud)
    {
        uint32 prescale;
        uint32 d;    
        uint32 ck;    
        float64   vclk = 90.000 * 1000000.0;
    
    /* USER CODE BEGIN (5) */
    /* USER CODE END */
        prescale = (uint32) ((vclk /8000000U) - 1U);
    
        if(prescale>=2U)
        {
    	d = 5U;
        }
        else
        {
    	d = (prescale != 0U) ? 6U : 7U;
        }
    
    	/*SAFETYMCUSW 96 S MR:6.1 <REVIEWED> "Calculations including int and float cannot be avoided" */
        ck = ((vclk)/(2U*baud*1000U*(prescale+1U)))-d;
    
        i2cREG1->PSC  = prescale;
        i2cREG1->CLKH = ck;
        i2cREG1->CLKL = ck;    
    
    /* USER CODE BEGIN (6) */
    /* USER CODE END */
    
    }
    
    /** @fn void i2cSetStart(i2cBASE_t *i2c)
    *   @brief Set i2c start condition
    *   @param[in] i2c  - i2c module base address
    *   Set i2c to generate a start bit (Only in Master mode)
    */
    void i2cSetStart(i2cBASE_t *i2c)
    {
    /* USER CODE BEGIN (7) */
    /* USER CODE END */
    
    	i2cREG1->MDR |= I2C_START_COND;  /* set start condition */
    
    /* USER CODE BEGIN (8) */
    /* USER CODE END */
    }
    
    /** @fn void i2cSetStop(i2cBASE_t *i2c)
    *   @brief Set i2c stop condition
    *   @param[in] i2c  - i2c module base address
    *   Set i2c to generate a stop bit (Only in Master mode)
    */
    void i2cSetStop(i2cBASE_t *i2c)
    {
    /* USER CODE BEGIN (9) */
    /* USER CODE END */
    
    	i2cREG1->MDR |= I2C_STOP_COND;  /* generate stop condition */
    
    /* USER CODE BEGIN (10) */
    /* USER CODE END */
    }
    
    /** @fn void i2cSetCount(i2cBASE_t *i2c,uint32 cnt)
    *   @brief Set i2c data count
    *   @param[in] i2c  - i2c module base address
    *   @param[in] cnt  - data count
    *   Set i2c count to a transfer value after which the stop condition needs to be generated.
    *   (Only in Master Mode)
    */
    void i2cSetCount(i2cBASE_t *i2c ,uint32 cnt)
    {
    /* USER CODE BEGIN (11) */
    /* USER CODE END */
    
    	i2cREG1->CNT = cnt;  /* set i2c count  */
    
    /* USER CODE BEGIN (12) */
    /* USER CODE END */
    }
    
    /** @fn uint32 i2cIsTxReady(i2cBASE_t *i2c)
    *   @brief Check if Tx buffer empty
    *   @param[in] i2c - i2c module base address
    *
    *   @return The TX ready flag
    *
    *   Checks to see if the Tx buffer ready flag is set, returns
    *   0 is flags not set otherwise will return the Tx flag itself.
    */
    uint32 i2cIsTxReady(i2cBASE_t *i2c)
    {
    /* USER CODE BEGIN (13) */
    /* USER CODE END */
    
        return i2cREG1->STR & I2C_TX_INT;
    
    /* USER CODE BEGIN (14) */
    /* USER CODE END */
    }
    
    /** @fn void i2cSendByte(i2cBASE_t *i2c, uint8 byte)
    *   @brief Send Byte
    *   @param[in] i2c  - i2c module base address
    *   @param[in] byte - byte to transfer
    *
    *   Sends a single byte in polling mode, will wait in the
    *   routine until the transmit buffer is empty before sending
    *   the byte.  Use i2cIsTxReady to check for Tx buffer empty
    *   before calling i2cSendByte to avoid waiting.
    */
    void i2cSendByte(i2cBASE_t *i2c, uint8 byte)
    {
    /* USER CODE BEGIN (15) */
    /* USER CODE END */
    
        while ((i2cREG1->STR & I2C_TX_INT) == 0U) 
        { 
    	} /* Wait */
        i2cREG1->DXR = byte;
    
    /* USER CODE BEGIN (16) */
    /* USER CODE END */
    }
    
    /** @fn void i2cSend(i2cBASE_t *i2c, uint32 length, uint8 * data)
    *   @brief Send Data
    *   @param[in] i2c    - i2c module base address
    *   @param[in] length - number of data words to transfer
    *   @param[in] data   - pointer to data to send
    *
    *   Send a block of data pointed to by 'data' and 'length' bytes
    *   long.  If interrupts have been enabled the data is sent using
    *   interrupt mode, otherwise polling mode is used.  In interrupt
    *   mode transmission of the first byte is started and the routine
    *   returns immediately, i2cSend must not be called again until the
    *   transfer is complete, when the i2cNotification callback will
    *   be called.  In polling mode, i2cSend will not return  until 
    *   the transfer is complete.
    *
    *   @note if data word is less than 8 bits, then the data must be left
    *         aligned in the data byte.
    */
    void i2cSend(i2cBASE_t *i2c, uint32 length, uint8 * data)
    {
        uint32 index = i2c == i2cREG1 ? 0U : 1U;
    
    /* USER CODE BEGIN (17) */
    /* USER CODE END */
    
        if ((g_i2cTransfer_t[index].mode & I2C_TX_INT) != 0U)
        {
            /* we are in interrupt mode */
            
            g_i2cTransfer_t[index].length = length;
            g_i2cTransfer_t[index].data   = data;
    
            /* start transmit by sending first byte */        
            i2cREG1->DXR = *(g_i2cTransfer_t[index].data + 1U);
            i2cREG1->IMR = I2C_TX_INT;
        }
        else
        {
            /* send the data */
            while (length-- > 0U)
            {
                while ((i2cREG1->STR & I2C_TX_INT) == 0U) 
    		    { 
    	        } /* Wait */
                i2cREG1->DXR = *data++;
            }
        }
    /* USER CODE BEGIN (18) */
    /* USER CODE END */
    }
    
    /** @fn uint32 i2cIsRxReady(i2cBASE_t *i2c)
    *   @brief Check if Rx buffer full
    *   @param[in] i2c - i2c module base address
    *
    *   @return The Rx ready flag
    *
    *   Checks to see if the Rx buffer full flag is set, returns
    *   0 is flags not set otherwise will return the Rx flag itself.
    */
    uint32 i2cIsRxReady(i2cBASE_t *i2c)
    {
    /* USER CODE BEGIN (19) */
    /* USER CODE END */
    
        return i2cREG1->STR & I2C_RX_INT;
    
    /* USER CODE BEGIN (20) */
    /* USER CODE END */
    }
    
    
    /** @fn uint32 i2cRxError(i2cBASE_t *i2c)
    *   @brief Return Rx Error flags
    *   @param[in] i2c - i2c module base address
    *
    *   @return The Rx error flags
    *
    *   Returns the Rx framing, overrun and parity errors flags,
    *   also clears the error flags before returning.
    */
    uint32 i2cRxError(i2cBASE_t *i2c)
    {
        uint32 status = i2cREG1->STR & (I2C_AL_INT | I2C_NACK_INT);
    
    /* USER CODE BEGIN (21) */
    /* USER CODE END */
    
        i2cREG1->STR = I2C_AL_INT | I2C_NACK_INT;
    	
    /* USER CODE BEGIN (22) */
    /* USER CODE END */
        
    	return status;
    
    }
    
    /** @fn void i2cClearSCD(i2cBASE_t *i2c)
    *   @brief Clears the Stop condition detect flags.
    *   @param[in] i2c - i2c module base address
    *
    *   This function is called to clear the Stop condition detect(SCD) flag
    */
    void i2cClearSCD(i2cBASE_t *i2c)
    {
    /* USER CODE BEGIN (23) */
    /* USER CODE END */
    
        i2cREG1->STR = I2C_SCD_INT;
    	
    /* USER CODE BEGIN (24) */
    /* USER CODE END */
    }
    
    /** @fn uint32 i2cReceiveByte(i2cBASE_t *i2c)
    *   @brief Receive Byte
    *   @param[in] i2c - i2c module base address
    *
    *   @return Received byte
    *
    *    Receives a single byte in polling mode.  If there is
    *    not a byte in the receive buffer the routine will wait
    *    until one is received.   Use i2cIsRxReady to check to
    *    see if the buffer is full to avoid waiting.
    */
    uint32 i2cReceiveByte(i2cBASE_t *i2c)
    {
        while ((i2cREG1->STR & I2C_RX_INT) == 0U) 
        { 
    	} /* Wait */
    /* USER CODE BEGIN (25) */
    /* USER CODE END */
    
        return i2cREG1->DRR;
    }
    
    /** @fn void i2cReceive(i2cBASE_t *i2c, uint32 length, uint8 * data)
    *   @brief Receive Data
    *   @param[in] i2c    - i2c module base address
    *   @param[in] length - number of data words to transfer
    *   @param[in] data   - pointer to data buffer
    *
    *   Receive a block of 'length' bytes long and place it into the 
    *   data buffer pointed to by 'data'.  If interrupts have been 
    *   enabled the data is received using interrupt mode, otherwise
    *   polling mode is used.  In interrupt mode receive is setup and
    *   the routine returns immediately, i2cReceive must not be called 
    *   again until the transfer is complete, when the i2cNotification 
    *   callback will be called.  In polling mode, i2cReceive will not
    *   return  until the transfer is complete.
    */
    void i2cReceive(i2cBASE_t *i2c, uint32 length, uint8 * data)
    {
    
    /* USER CODE BEGIN (26) */
    /* USER CODE END */
        if ((i2cREG1->IMR & I2C_RX_INT) != 0U)
        {
            /* we are in interrupt mode */
            uint32 index = i2c == i2cREG1 ? 0U : 1U;
            
            /* clear error flags */
            i2cREG1->STR = I2C_AL_INT | I2C_NACK_INT;
    
            g_i2cTransfer_t[index].length = length;
            g_i2cTransfer_t[index].data   = data;
        }
        else
        {   
            while (length-- > 0U)
            {
                while ((i2cREG1->STR & I2C_RX_INT) == 0U) 
    		    { 
    	        } /* Wait */
                *data++ = i2cREG1->DRR;
            }
        }
    
    /* USER CODE BEGIN (27) */
    /* USER CODE END */
    }
    
    /** @fn void i2cEnableLoopback(i2cBASE_t *i2c)
    *   @brief Enable Loopback mode for self test
    *   @param[in] i2c        - i2c module base address
    *
    *   This function enables the Loopback mode for self test.
    */
    void i2cEnableLoopback(i2cBASE_t *i2c)
    {
    /* USER CODE BEGIN (28) */
    /* USER CODE END */
    
        /* enable digital loopback    */
        i2cREG1->MDR |= (1U << 6U); 
    
    /* USER CODE BEGIN (29) */
    /* USER CODE END */
    }
    
    /** @fn void i2cDisableLoopback(i2cBASE_t *i2c)
    *   @brief Enable Loopback mode for self test
    *   @param[in] i2c        - i2c module base address
    *
    *   This function disable the Loopback mode.
    */
    void i2cDisableLoopback(i2cBASE_t *i2c)
    {
    /* USER CODE BEGIN (30) */
    /* USER CODE END */
        
    	/* Disable Loopback Mode */
        i2cREG1->MDR &= 0xFFFFFFBFU; 
    
    /* USER CODE BEGIN (31) */
    /* USER CODE END */
    }
    
    /** @fn i2cEnableNotification(i2cBASE_t *i2c, uint32 flags)
    *   @brief Enable interrupts
    *   @param[in] i2c   - i2c module base address
    *   @param[in] flags - Interrupts to be enabled, can be ored value of:
    *                      i2c_FE_INT    - framing error,
    *                      i2c_OE_INT    - overrun error,
    *                      i2c_PE_INT    - parity error,
    *                      i2c_RX_INT    - receive buffer ready,
    *                      i2c_TX_INT    - transmit buffer ready,
    *                      i2c_WAKE_INT  - wakeup,
    *                      i2c_BREAK_INT - break detect
    */
    void i2cEnableNotification(i2cBASE_t *i2c, uint32 flags)
    {
        uint32 index = i2c == i2cREG1 ? 0U : 1U;
    
    /* USER CODE BEGIN (32) */
    /* USER CODE END */
    
        g_i2cTransfer_t[index].mode |= (flags & I2C_TX_INT);
        i2cREG1->IMR               = (flags & (~I2C_TX_INT));
    }
    
    /** @fn i2cDisableNotification(i2cBASE_t *i2c, uint32 flags)
    *   @brief Disable interrupts
    *   @param[in] i2c   - i2c module base address
    *   @param[in] flags - Interrupts to be disabled, can be ored value of:
    *                      i2c_FE_INT    - framing error,
    *                      i2c_OE_INT    - overrun error,
    *                      i2c_PE_INT    - parity error,
    *                      i2c_RX_INT    - receive buffer ready,
    *                      i2c_TX_INT    - transmit buffer ready,
    *                      i2c_WAKE_INT  - wakeup,
    *                      i2c_BREAK_INT - break detect
    */
    void i2cDisableNotification(i2cBASE_t *i2c, uint32 flags)
    {
        uint32 index = i2c == i2cREG1 ? 0U : 1U;
    
    /* USER CODE BEGIN (33) */
    /* USER CODE END */
    
        g_i2cTransfer_t[index].mode &= ~(flags & I2C_TX_INT);
        i2cREG1->IMR               = (flags & (~I2C_TX_INT));
    }
    
    
    
    

  • Hi Charles,

    I found on line a TI document with an I2C example (spna082.pdf). I was able to write a simple function and measure SCL and SDA signals. Now is a matter of time to develop the other functions for writing/reading the I2C memory.

    I will look in the file you sent me, maybe I will take something from there too.

    Thanks,

    Marius

    spna082.pdf