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.

TMS320F2800137: MCP79410 RTC interfacing issue with TMS320F2800137 over I2C - No SDA activity

Part Number: TMS320F2800137
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hello TI Community,

I am trying to interface the MCP79410 RTC IC with the TMS320F2800137 microcontroller using the I2C communication protocol. I am using I2C pins of the MCU for this connection. However, I am not seeing any data activity on the SDA line, and the communication does not seem to be taking place.

Here’s what I’ve done:

Connected the SCL and SDA lines with 4.7k pull-up resistors.

Configured I2C in master-transmitter mode.

Verified pin muxing for the I2C lines.

The MCP79410 address is 0x6F as per the datasheet.

Here’s what I’ve done:                                                                                                                                                                                                                                            

Connected the SCL and SDA lines with 10k pull-up resistors.

Configured I2C in master-transmitter mode.

Verified pin muxing for the I2C lines.

The MCP79410 address is 0x6F as per the datasheet.


I have attached:

1. The source code I am using.

//#############################################################################
//
// FILE:   empty_driverlib_main.c
//
//! \addtogroup driver_example_list
//! <h1>Empty Project Example</h1> 
//!
//! This example is an empty project setup for Driverlib development.
//!
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2024 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 "driverlib.h"
#include "device.h"
#include "board.h"
#include "c2000ware_libraries.h"

#define MCP79410_ADDRESS 0x6F

uint8_t hours, minutes, seconds;

void RTC_setTime(uint8_t hours, uint8_t minutes, uint8_t seconds);
void RTC_getTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds);

// // ===== Function Prototypes =====
 void initI2C(void);
// void mcp79410_writeByte(uint8_t regAddr, uint8_t data);
// uint8_t mcp79410_readByte(uint8_t regAddr);
 void mcp79410_setTime(void);
 void mcp79410_readTime(void);
// uint8_t bcdToDec(uint8_t val);


// uint8_t data;
// uint8_t raw_seconds;
// uint8_t raw_minutes;
// uint8_t raw_hours;
// uint8_t seconds;
// uint8_t minutes;
// uint8_t hours;

//     uint8_t i;
//     uint8_t timeData[3];

//
// Main
//

void main(void)
{

    //
    // Initialize device clock and peripherals
    //
    Device_init();

    //
    // Disable pin locks and enable internal pull-ups.
    //
    Device_initGPIO();

    //
    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    //
    Interrupt_initModule();

    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    //
    Interrupt_initVectorTable();

    //
    // PinMux and Peripheral Initialization
    //
    Board_init();

    //
    // C2000Ware Library initialization
    //
    C2000Ware_libraries_init();

    //
    // Enable Global Interrupt (INTM) and real time interrupt (DBGM)
    //
    // EINT;
    // ERTM;
 
    initI2C();

    I2C_setSlaveAddress(I2CA_BASE, MCP79410_ADDRESS);  // Set RTC address

    RTC_setTime(12, 30, 45);  // Set time to 12:30:45

    while (1) {
        RTC_getTime(&hours, &minutes, &seconds);
        DEVICE_DELAY_US(1000000);  // Delay 1 second
    }

}

//
// End of File
//

void initI2C(void)
{
    // I2C SDA and SCL pin setup
    GPIO_setPinConfig(GPIO_32_I2CA_SDA);
    GPIO_setPadConfig(33, GPIO_PIN_TYPE_PULLUP);
    GPIO_setQualificationMode(33, GPIO_QUAL_ASYNC);

    GPIO_setPinConfig(GPIO_33_I2CA_SCL);
    GPIO_setPadConfig(32, GPIO_PIN_TYPE_PULLUP);
    GPIO_setQualificationMode(32, GPIO_QUAL_ASYNC);

    // I2C Master config
    I2C_disableModule(I2CA_BASE);
    I2C_initMaster(I2CA_BASE, DEVICE_SYSCLK_FREQ, 100000, I2C_DUTYCYCLE_33);
    I2C_setAddressMode(I2CA_BASE, I2C_ADDR_MODE_7BITS);
    I2C_setBitCount(I2CA_BASE, I2C_BITCOUNT_8);
    I2C_setSlaveAddress(I2CA_BASE, MCP79410_ADDRESS);
    I2C_setEmulationMode(I2CA_BASE, I2C_EMULATION_FREE_RUN);
    I2C_enableModule(I2CA_BASE);
}



// void I2C_init(void) {
//     // Initialize I2C as master
//     I2C_initMaster(I2CA_BASE, DEVICE_SYSCLK_FREQ, 100000, I2C_DUTYCYCLE_33);
//     I2C_setSlaveAddress(I2CA_BASE, RTC_I2C_ADDR);
//     I2C_enableModule(I2CA_BASE);
// }

void RTC_setTime(uint8_t hours, uint8_t minutes, uint8_t seconds) {
    I2C_setConfig(I2CA_BASE, I2C_MASTER_SEND_MODE);
    I2C_sendStartCondition(I2CA_BASE);
    I2C_putData(I2CA_BASE, 0x00);  // Address of seconds register
    I2C_putData(I2CA_BASE, seconds);
    I2C_putData(I2CA_BASE, minutes);
    I2C_putData(I2CA_BASE, hours);
    I2C_sendStopCondition(I2CA_BASE);
}

uint8_t bcdToDec(uint8_t val)
{
    return ((val >> 4) * 10 + (val & 0x0F));
}

void RTC_getTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds)
{
    // Step 1: Set register pointer to 0x00 (seconds register)
    I2C_setConfig(I2CA_BASE, I2C_MASTER_SEND_MODE);
    I2C_sendStartCondition(I2CA_BASE);
    I2C_putData(I2CA_BASE, 0x00);  // Point to seconds register
    while(I2C_isBusBusy(I2CA_BASE));
    
    // Step 2: Repeated start for reading
    I2C_setConfig(I2CA_BASE, I2C_MASTER_RECEIVE_MODE);
    I2C_sendStartCondition(I2CA_BASE);

    uint8_t rawSeconds = I2C_getData(I2CA_BASE);
    uint8_t rawMinutes = I2C_getData(I2CA_BASE);
    uint8_t rawHours   = I2C_getData(I2CA_BASE);

    I2C_sendStopCondition(I2CA_BASE);

    // Step 3: Convert from BCD to decimal
    *seconds = bcdToDec(rawSeconds & 0x7F);  // Mask ST bit
    *minutes = bcdToDec(rawMinutes);
    *hours   = bcdToDec(rawHours & 0x3F);    // Mask 24-hour mode bits
}

2. Oscilloscope waveforms of the SCL and SDA lines during I2C communication attempts.

I would appreciate it if you could help me identify what might be going wrong or what I'm missing.

Thank you in advance.

  • Hi Govind,

    What hardware is being used? Is this a custom board or using one of our EVMs?

    It looks like you are using SysConfig. What is being configured in the SysConfig file and is any peripheral initialization being used in it?

    Can you provide scope images of the data packets being sent out by the F2800137 MCU?

    Regards,

    Peter