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.

I2C PROTOCOL HALCOGEN

Other Parts Discussed in Thread: HALCOGEN, TMS570LS2124, TMS570LC4357, TMS570LS1224

While   using   i2c   protocol    TMS570LS4357   as   master     TMS570LS2124   as    Slave    please  provide   me   halcogen   set  up    ,then    while  excuting   the  example  code   it  is  get   struck   in   while loop 

while(i2cIsStopDetected (i2cREG1) I2C_SCD_INT);    HOW  over  come   from  this  problem  , please  provide    one  solution   as  soon as  possible   

thank you   for   help

regards

jeeva

  • Hi Jeeva,

    What are the values of external pull-ups you are using?

    0636.I2C_TEST_LC43.zip

    Can you please verify your code with above tested example once?

    --

    Thanks & regards,
    Jagadish.

  • IAM  USING   EXAMPLE  CODE  MASTER  AND  SLAVE  USING  CONTROLLER  TMS570LS4357 AS  MASTER AND  TMS570LS2124  AS  SLAVE  

  • IAM  USING   EXAMPLE  CODE  MASTER  AND  SLAVE  USING  CONTROLLER  TMS570LS4357 AS  MASTER AND  TMS570LS2124  AS  SLAVE  

    Okay, but i would like to know the external pull-up values you are using on SDA and SCL lines?

  • what   sir  no reply  from  u r  side 

  • what   sir  no reply  from  u r  side 

  • if  i  used  controller  in halcogen  pull up ,pull down  then  it  required  external resistor 

  • some  one   tell   me   how to  over come   from   struck  in  busbusy function  in  master 

  • Hi Jeev,

    I will provide you an update on monday, as it is a weekend i don’t have setup with me right now.

    Mean while please attach your master and slave projects.

    Thanks,

    Jagadish.

  • #include "sys_common.h"
    /* USER CODE BEGIN (1) */
    #include "i2c.h"
    /* USER CODE END */
    /* USER CODE BEGIN (2) */
    #define DATA_COUNT 10
    #define Master_Address 0x26
    #define Slave_Address 0x8
    uint8_t TX_Data_Master[10] = { 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19};
    uint8_t RX_Data_Master[10] = { 0 };
    uint8_t TX_Data_Slave[10] = { 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29};
    uint8_t RX_Data_Slave[10] = { 0 };
    /* USER CODE END */
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    int repeat = 0; int delay =0;
    // Master Transfer Functionality //
    /* I2C Init as per GUI
    * Mode = Master - Transmitter
    * baud rate = 100KHz
    * Count = 10
    * Bit Count = 8bit
    */
    i2cInit();
    /* Configure address of Slave to talk to */
    i2cSetSlaveAdd(i2cREG1, Slave_Address);
    /* Set direction to Transmitter */
    /* Note: Optional - It is done in Init */
    i2cSetDirection(i2cREG1, I2C_TRANSMITTER);
    for(repeat = 0; repeat < 2; repeat++)
    {
    /* 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 */
    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<1000000;delay++);
    }
    // Master Receive Functionality //
    /* Configure address of Slave to talk to */
    i2cSetSlaveAdd(i2cREG1, Slave_Address);
    /* Set direction to receiver */
    i2cSetDirection(i2cREG1, I2C_RECEIVER);
    for(repeat = 0; repeat < 2; repeat++)
    {
    /* 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);
    /* Simple Dealya before starting Next Block */
    /* Depends on how quick the Slave gets ready */
    for(delay=0;delay<1000000;delay++);
    }
    asm(" nop");
    asm(" nop");
    asm(" nop");
    while(1);
    /* USER CODE END */
    above  one  master code  
    #include "sys_common.h"
    /* USER CODE BEGIN (1) */
    #include "i2c.h"
    /* USER CODE END */
    /* USER CODE BEGIN (2) */
    #define DATA_COUNT 10
    #define Slave_Address 0x8
    uint8_t TX_Data_Master[10] = { 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19};
    uint8_t RX_Data_Master[10] = { 0 };
    uint8_t TX_Data_Slave[10] = { 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29};
    uint8_t RX_Data_Slave[10] = { 0 };
    /* USER CODE END */
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    int repeat = 0;
    // Slave Receiver Functionality //
    /* I2C Init as per GUI
    * Mode = Slave - Receiver
    * baud rate = 100KHz
    * Count = 10
    * Bit Count = 8bit
    */
    i2cInit();
    /* Configure own address so that master can use it as slave address */
    i2cSetOwnAdd(i2cREG1, Slave_Address);
    /* Set direction to receiver */
    /* Note: Optional - It is done in Init */
    i2cSetDirection(i2cREG1, I2C_RECEIVER);
    for(repeat = 0; repeat < 2; repeat++)
    {
    /* Configure Data count */
    /* Note: Optional - It is done in Init, unless user want to change */
    i2cSetCount(i2cREG1, DATA_COUNT);
    /* Tranmit DATA_COUNT number of data in Polling mode */
    i2cReceive(i2cREG1, DATA_COUNT, RX_Data_Slave);
    /* 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);
    }
    // Slave Transmit Functionality //
    /* Configure own address so that master can use it as slave address */
    i2cSetOwnAdd(i2cREG1, Slave_Address);
    /* Set direction to receiver */
    i2cSetDirection(i2cREG1, I2C_TRANSMITTER);
    for(repeat = 0; repeat < 2; repeat++)
    {
    /* Configure Data count */
    /* Note: Optional - It is done in Init, unless user want to change */
    i2cSetCount(i2cREG1, DATA_COUNT);
    /* Tranmit DATA_COUNT number of data in Polling mode */
    i2cSend(i2cREG1, DATA_COUNT, TX_Data_Slave);
    /* 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);
    }
    this  are   example   code  ,please  provide   me  set up  of  halcogen   and   give   me   solution   overcome  from  that   loop  both  master   and  slave  ,later   i   need   to   work  on  temperature   so   kindly  reply  me  as  soon as  possible
  • #include "sys_common.h"
    /* USER CODE BEGIN (1) */
    #include "i2c.h"
    /* USER CODE END */
    /* USER CODE BEGIN (2) */
    #define DATA_COUNT 10
    #define Master_Address 0x26
    #define Slave_Address 0x8
    uint8_t TX_Data_Master[10] = { 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19};
    uint8_t RX_Data_Master[10] = { 0 };
    uint8_t TX_Data_Slave[10] = { 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29};
    uint8_t RX_Data_Slave[10] = { 0 };
    /* USER CODE END */
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    int repeat = 0; int delay =0;
    // Master Transfer Functionality //
    /* I2C Init as per GUI
    * Mode = Master - Transmitter
    * baud rate = 100KHz
    * Count = 10
    * Bit Count = 8bit
    */
    i2cInit();
    /* Configure address of Slave to talk to */
    i2cSetSlaveAdd(i2cREG1, Slave_Address);
    /* Set direction to Transmitter */
    /* Note: Optional - It is done in Init */
    i2cSetDirection(i2cREG1, I2C_TRANSMITTER);
    for(repeat = 0; repeat < 2; repeat++)
    {
    /* 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 */
    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<1000000;delay++);
    }
    // Master Receive Functionality //
    /* Configure address of Slave to talk to */
    i2cSetSlaveAdd(i2cREG1, Slave_Address);
    /* Set direction to receiver */
    i2cSetDirection(i2cREG1, I2C_RECEIVER);
    for(repeat = 0; repeat < 2; repeat++)
    {
    /* 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);
    /* Simple Dealya before starting Next Block */
    /* Depends on how quick the Slave gets ready */
    for(delay=0;delay<1000000;delay++);
    }
    asm(" nop");
    asm(" nop");
    asm(" nop");
    while(1);
    /* USER CODE END */
    above  one  master code  
    #include "sys_common.h"
    /* USER CODE BEGIN (1) */
    #include "i2c.h"
    /* USER CODE END */
    /* USER CODE BEGIN (2) */
    #define DATA_COUNT 10
    #define Slave_Address 0x8
    uint8_t TX_Data_Master[10] = { 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19};
    uint8_t RX_Data_Master[10] = { 0 };
    uint8_t TX_Data_Slave[10] = { 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29};
    uint8_t RX_Data_Slave[10] = { 0 };
    /* USER CODE END */
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    int repeat = 0;
    // Slave Receiver Functionality //
    /* I2C Init as per GUI
    * Mode = Slave - Receiver
    * baud rate = 100KHz
    * Count = 10
    * Bit Count = 8bit
    */
    i2cInit();
    /* Configure own address so that master can use it as slave address */
    i2cSetOwnAdd(i2cREG1, Slave_Address);
    /* Set direction to receiver */
    /* Note: Optional - It is done in Init */
    i2cSetDirection(i2cREG1, I2C_RECEIVER);
    for(repeat = 0; repeat < 2; repeat++)
    {
    /* Configure Data count */
    /* Note: Optional - It is done in Init, unless user want to change */
    i2cSetCount(i2cREG1, DATA_COUNT);
    /* Tranmit DATA_COUNT number of data in Polling mode */
    i2cReceive(i2cREG1, DATA_COUNT, RX_Data_Slave);
    /* 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);
    }
    // Slave Transmit Functionality //
    /* Configure own address so that master can use it as slave address */
    i2cSetOwnAdd(i2cREG1, Slave_Address);
    /* Set direction to receiver */
    i2cSetDirection(i2cREG1, I2C_TRANSMITTER);
    for(repeat = 0; repeat < 2; repeat++)
    {
    /* Configure Data count */
    /* Note: Optional - It is done in Init, unless user want to change */
    i2cSetCount(i2cREG1, DATA_COUNT);
    /* Tranmit DATA_COUNT number of data in Polling mode */
    i2cSend(i2cREG1, DATA_COUNT, TX_Data_Slave);
    /* 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);
    }
    this  are   example   code  ,please  provide   me  set up  of  halcogen   and   give   me   solution   overcome  from  that   loop  both  master   and  slave  ,later   i   need   to   work  on  temperature   so   kindly  reply  me  as  soon as  possible
  • Hi Jeev,

    Today i tested your codes on my boards.

    On my testing, i used

    TMS570LC4357 as Master 

    and RM57L853 as slave because i don't have TMS570LS1224  board.

    Here are my testing projects:
    3617.I2C_TEST_LC43.zip

    RM57_I2C_Slave.zip

    And after my testing, i didn't see any issues in my testing. I also attached the logic analyzer and monitor the signals.

    Here is the output of the logic analyzer.

    I could see, you are sending 11 bytes with time difference of 36.66mSec

    And first two times you are sending below data:

    Slave address(0x08) And 0x10 to the 0x19 data to the slave.

    And Next two times you are sending below data:

    Slave address(0x08) And 0x20 to the 0x29 data to the slave.

    So my suggesting here is below thing:

    1. On my testing i used 2.2K pullup resistors. And make sure to use only one pair of pull-up resistors, i mean don't use pull-up resistors on both master and slave sides because if we did that the overall pull-up resistor value becomes 1.1k.

    2. Even though i used same as your code but my HALCoGen configuration is not same as yours, so my sincere suggestion here is just cross check my HALCoGen configuration files of master and slave with yours. Because your initialization code and my code might be different. So please do that.

    If you follow above two suggestions, i think your code also should work.

    --

    Thanks & regards,
    Jagadish.