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.

TMS320F28035: I2C Master Receiver and Slave Transmitter Problem

Part Number: TMS320F28035
Other Parts Discussed in Thread: C2000WARE

Hello,

I am working on I2C Master Receiver and Slave Transmitter.

In Slave Transmitter Interrupt, Transmit Interrupt (I2C_TX_ISRC) enters before Address as Slave Interrupt (I2C_AAS_ISRC).

This causes index confusion.

I have attached the relevant files.

I would appreciate if you share an I2C Slave example for TMS320F28035.

Thanks,

Kadir B.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//###########################################################################
//
//! \addtogroup f2803x_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. T
//! (e.g. F2803x eZdsp)
//!
//! \b Watch \b Variables \n
//! - I2cMsgIn1
//! - I2cMsgOut1
//
//###########################################################################
// $TI Release: F2803x C/C++ Header Files and Peripheral Examples V129 $
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//###########################################################################
//
//! \addtogroup f2803x_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. T
//! (e.g. F2803x eZdsp)
//!
//! \b Watch \b Variables \n
//! - I2cMsgIn1
//! - I2cMsgOut1
//
//###########################################################################
// $TI Release: F2803x C/C++ Header Files and Peripheral Examples V129 $
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Kadir,

    Our expert will get back on this issue today.

  • Hello Kadir,

    There is an I2C example for this device located here (C2000Ware_X_XX_XX_XX\device_support\f2803x\examples\c28\i2c_eeprom).

    To clarify, are you using two different F28035 devices, where one is a slave and the other is master? Also, can you send a screenshot of the waveform that is received?

    Best regards,

    Omer Amir

  • Hi Omer,

    First of all, thank you for your feedback.

    I already know, there is an I2C example for F28035 but just Master not for Slave.

    Yes, I am using two different F28035 devices, one is Master Receiver, and the other is Slave Transmitter.

    I am sending screenshot of the PicoScope waveform and file.

    Thanks,

    Kadir B.

  • Hello Kadir,

    I've looked over your code and compared it to the screenshot, and there is one thing I am curious about. For the master code, it sets the slave address as 2, but in the slave code its own address is set as 0x68. I've looked in the I2CSAR/I2COAR registers, and from what I understand they should match between the slave and master. This may be what's causing the Address as Slave Interrupt to not be entered in first, although I'm not sure why it goes to the transmit interrupt instead, but perhaps if you can clarify the addressing question than I can look into it.

    Best regards,

    Omer Amir

  • Hi Omer,

    I accidentally send the wrong code. 

    I work Slave Address as 2.

    I encountered the problem when Slave Address as 2.

  • Hi Kadir,

    Okay, that helps. Also, the I2C transmission you screenshotted is coming from master, correct? And that's why you're expecting the I2C_AAS_ISRC flag to be set? And in its place, you are getting a transmit-data-ready flag that's set, meaning the slave is ready to transmit but the communication has not been started.

    Best regards,

    Omer Amir

  • Hi Omer,

    I2C transmission starts with the Master sending the address, after Slave send data.

    In Address as Slave interrupt, I clear the index of the tranmission buffer. (TxBuffer), after Slave send data in Transmission interrrupt.

    I use Address as Slave interrupt for clear index.

    Thanks,

    Kadir B.

  • Hello Kadir,

    If you comment out all the other interrupt flags except the "Address as Slave", does it reach that point in the code? Or is it never triggered at all?

    Best regards,

    Omer Amir

  • Hi Omer,

    I comment out all the other interrupt flags except the "Address as Slave".

    "Transmit-data-ready" is triggered.

    I am sharing screenshots.

    Thanks,

    Kadir B.

      

  • Hi Kadir,

    Sorry if it wasn't clear, but I meant remove everything in your switch statement so the "Address as Slave" case is the only one available, like so:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    switch (IntSource) {
    /*case I2C_RX_ISRC:
    I2C_RXBuffer[I2C_RXIndex++] = I2caRegs.I2CDRR;
    I2caRegs.I2CSTR.bit.RRDY = 1;
    break;
    case I2C_TX_ISRC:
    I2C_TXISRCCount++;
    I2caRegs.I2CDXR = I2C_TXBuffer[I2C_TXIndex++];
    break;*/
    case I2C_AAS_ISRC:
    I2C_AASISRCCount++;
    I2C_TXIndex = 0;
    I2C_RXIndex = 0;
    break;
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Best regards,

    Omer Amir

  • Hello Omer,

    Sorry for my miss understanding.

    I could trigger only once the "Address as Slave" from Master. 

    I think stop condition does not occur.

    Thanks,

    Kadir B.

  • Hi Kadir,

    When you say you triggered the "Address as Slave" from master, do you mean it was triggered in the code for the slave device or master device? And on what basis does it seem like the stop condition is not occurring?

    Best regards,

    Omer Amir