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.

TMS570LS1227: Wake-up signal over SDA line for the I2C device

Part Number: TMS570LS1227
Other Parts Discussed in Thread: HALCOGEN,

Hi,

I am using the TMS570LS12x HDK with a custom  specific I2C slave device. The slave device has the SDA, SCL, ov, 3.3v pins.

I have connected the J11 pin 72(B2) for SDA line and J11 pin 71(C3) for SCL. I cannot find the port for 3.3v from HDK, so i connected the TP21 to 3.3v pin of I2C slave device and 0v from the J11 ground.

The slave device will be in sleep mode when we supply power for the first time. To change from sleep mode to normal mode after power-on, a wake-up token having a specific waveform
needs to be sent through SDA pin. The slave received the wake-up token is switched to normal mode. In normal when we read the slave device with slave address it will return 4 bytes of data to confirm its woken up.

Black circle (Wake-up Low Duration): 80 μs
Black circle (Wake-up High delay to data communication)
- After sleep : 10 ms

Can you please let me know how to drive the SDA line alone once we initialize the I2C master to achieve this wake-up token? I am trying with sending data 0x00 over SDA line to acheive this but i cannot see the slave responding.

I am using the HalCoGen generated code for I2C from the demo. The baud rate is set to 100kHz. 

Thanks,

Best Regards,

-Dinesh

  • Hello Dinesh,

    generally the SDA pin can not be driven alone once I2C interface is initialized.

    Theoretically using a 0x00 byte sent alone should do the job as you suppose but you will need to connect a scope to see actual timings and adjust.

    Also makes sense to see if SCL clock is exactly 100kHz during transactions.

    BR

    Michail

  • Hi Michail,

    Thanks for your reply. I am trying the following to generate the wakeup token, 

    #define Slave_Address  0x00

    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);

    /* Set mode as Master */

    i2cSetMode(i2cREG1, I2C_MASTER);

    /* Set Stop after programmed Count */
    i2cSetStop(i2cREG1); //CNT register set to 8 bit by Halcogen

    /* Transmit Start Condition */
    i2cSetStart(i2cREG1);

    /* Tranmit DATA_COUNT number of data in Polling mode */
    i2cSend(i2cREG1, DATA_COUNT, 0x00); //DATA_COUNT =1

    /* 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);

    In the above mentioned code the control looping at while(i2cIsStopDetected(i2cREG1) == 0); function checking for STR register SCD bit value but it is always set to 0 while executing this line of code. Not sure whether the sequence is correct and master would have sent the 0x00 bytes to the slave.

    Is the sequence above correct?

    Thanks,

    Best Regards,

    -DInesh

  • Hello,

    CNT field of I2CCNT defines number of words. You can use i2cSetCount to set CNT field to override HALCoGen settings.

    Best regards,

    Miro

  • Hi Miro,

    I have updated the code as below,

    #define Slave_Address  0x00

    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);

    /* Configure Data count */
    /* Note: Optional - It is done in Init, unless user want to change */
    i2cSetCount(i2cREG1, 0x01);

    /* Set mode as Master */

    i2cSetMode(i2cREG1, I2C_MASTER);

    /* Set Stop after programmed Count */
    i2cSetStop(i2cREG1); //CNT register set to 8 bit by Halcogen

    /* Transmit Start Condition */
    i2cSetStart(i2cREG1);

    /* Tranmit DATA_COUNT number of data in Polling mode */
    i2cSend(i2cREG1, DATA_COUNT, 0x00); //DATA_COUNT =1

    /* 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);

     

    Its the same. It always stuck with the while(i2cIsStopDetected(i2cREG1) == 0); function.

    the MDR settings by Halcogen,

    /** - set i2c mode */
    i2cREG1->MDR = (0 << 15) /* nack mode */
    | (0 << 14) /* free running */
    | 0 /* start condition - master mode only */
    | (1 <<11) /* stop condition */
    | (1 <<10) /* Master/Slave mode */
    | (I2C_TRANSMITTER) /* Transmitter/receiver */
    | (I2C_7BIT_AMODE) /* xpanded address */
    | (0 << 7) /* repeat mode */
    | (0 << 6) /* digital loopback */
    | (0 << 4) /* start byte - master only */
    | (0 << 3) /* free data format */
    | I2C_8_BIT; /* bit count */

    Thanks,

    Best Regards,

    -DInesh

  • Hello,
    Try to set IGNACK bit of I2CEMDR register. In that way Master will ignore NACK from the Slave.

    Best regards,

    MIro

  • Hi Miro,

    I set the bit but its still same. I attached the code that i am using for this experiment. The execution stuck at the file SysMain.c line number 89. This means that i doubt the Master is transmitting anything over the I2C bus.

    Could you please kindly have a look and suggest me whats missing in this?

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/312/8666.source.7z

    Thanks,

    -Dinesh

  • Hi Miro,

    With the code i attached the following are occurring,

    I am executing this using the code composer debugger step by step,

    The STR register is starting with 0x00000410 after i2c_init() has been called the STR value remains same.

    the BB bit never get set in STR, even after i2cSetStart() called.

    Thanks,

    Best Regards,

    -DInesh

  • Hi Miro,

    While i still have the issue described before,

    I wanted to make sure whether the SDA line and SCL are working fine by flashed other simple blinky example that doesn't use the I2C module.

    I measured the voltage between the ground and SDA its 3.2v, gorund and SCL its 3.2v as  well. Is this the ideal condition?

    Early response would be really appreciated.

    Thanks,

    Best Regards,

    -Dinesh

  • Hello Dinesh,

    While I2C bus is idle SDA and SCL must be high. SDA and SCL line must have pull-ups connected to VCCIO (R83 and R84 on HDK).

    Do you have oscilloscope or logic analyzer to confirm that Master is trying to communicate with Slave?

    There is an examples for I2C under HALCoGen folder. From Help-->Help topics-->examples you can see how I2C has to be set.

    Best regards,

    Miro

  • Hi Miro,

    I have been following the examples from the HalCoGen as you mentioned.

    The issue is its always stuck in the (i2cIsStopDetected(i2cREG1) == 0); function.

    I have disconnected the i2c device and ran the code. It is the same. Means the issue that i am having is same irrespective of the device is connected or not.

    Do you have any suggestion on this?

    Thanks,

    Best Regards,

    -Dinesh

  • Hi Miro,

    I have tried the example for I2C under HALCoGen folder. From Help-->Help topics-->examples you can see how I2C has to be set.

    If i follow the code after the i2cSetStart(i2cREG1); function the BB bit was never set. The value of the STR is 0x00000410

    Any reason why the BB has not been set? Start and stop condition are never set. All the time both SDA/SCL stays high.

    Thanks,

    Best Regards,

    -Dinesh

  • Hello,

    I am sorry for the late reply.

    I am doing some test with this cse and I need a little bit more time. For now I think it is better for you to use extra GIO with open drain functionality to drive SDA line for waking-up the device.

    If IGNACK is set this means that master will ignore NACK but line will go high and in this case you have to finish wake-up during the address part of  the message.

    Best regards,
    Miro

  • Hi Miro,

    Thanks for the reply.

    In that case do i need to connect the SDA pin of the slave to SDA pin of Master and also to the GIO of master to acheive this?

    Could you please help me if i configure the GIO and connect to the slave SDA how to drive the PIN low for 80us? Sample code would help me a lot.

    Thanks,

    Best Regards,

    -Dinesh

  • Dinesh,

    Please make sure that the I/O multiplexing is set up correctly to output I2C signals on to the assigned terminals. These are not the default assignments and the "Pinmux" tab in HALCoGen needs to be configured to enable I2C outputs.

    Regards,

    Sunil

  • Hi Sunil,

    Thanks a lot for your reply. I have configured the pin mux correctly. Now i can able to transmit the data over SDA lines. Means its not stuck with IsStopdetected() function. 

    The thing that i cannot able to achieve is the wakup pattern.I have been trial and error sending the data but there is no response from the slave. the control stuck at  i2cReceive() function while ((i2c->STR & (uint32)I2C_RX_INT) == 0U) condition.Figuring out how to send the wakeup pattern before the i2c transfer happens.

    Would be great if you could help on this.

    Thanks,

    Best Regards,

    -Dinesh

  • As Miro mentioned, you would need to drive this signal as an I/O pin (versus an I2C functional pin) to create the required wake up pattern for the slave device. You can configure the SDA signal as an I/O pin and use the I2C module's I/O drive capability and then switch the signal back to being an I2C functional signal.

    - Sunil

  • Hi Dinesh,

    Assume the issue has been resolved.

  • Hi,

    Sorry it took a while to come back. Actually i was waiting for my Logical analyzer to arrive to continue my test.

    Using logic analyser i confirmed the required wake up wave form has been produced from  the master(TMS570LS) i2c and the slave acknowledged the wakeup token. I have done the following,

    Init the i2c module as GIO for sda and scl lines. produced the wake up token by lowering the sda and scl line for 80  micro seconds.

    Reinit the i2c modue as i2c function for sda and scl lines. set the slave address, set direction as receiver, set count to 4, set mode to master, set stop, set start, i2c receive, check bus busy, check stop detected and clear scd. And run into infinite loop. Here when the slave ack the wakeup pattern it transmits the 04 11 33 43 response but the master always read 00 00 00 00. Have no idea why is this. Some times i see the master read 04 11 33 43, but not in the next consecutive run. Strange.

    I also found a strange behaviour,

    i send the wakeup token through i2c gio mode, read the slave in i2c mode, master reads 00 00 00 00. In this case if i terminate the debugger in CCS, remove  the power from  the HDK and attach back the power, re-flash the sw, i see the buffer is updated with 04 11 33 43 immediately before i start the software. I think this is the response from  the slave in the previous power cycle, it stored some where. Cannot figure out.

    Note1: I have attached the snap1, when the master reads the response from slave. In that 1. the power reset(low the sda and scl for 0.1sec) 2.wakeup token(low the sda for minimum 80 micro seconds) 3. i2c receive packet from slave(04 11 33 43)

    Note 2:I have attached the snap2, when the master reads the response from slave. In that 1. the power reset(low the sda and scl for 0.1sec) 2.wakeup token(low the sda for minimum 80 micro seconds) 3. i2c receive packet from slave(00 00 00 00)

    It would be great if you could support asap as we are running out of time. If requires i would schedule a WebEx to go through this issue.

    Thanks in advance for your support.

    Best Regards,

    -Dinesh  

  • Hi Guys,

    I managed to resolve this issue. The response 04 11 33 43 will be every time we power reset & wakeup the i2c chip. if no power reset but wake up token alone we get 00 00 00 00 which is the one i am getting and it is correct response.

    Now i can able to use that chip with the TMS570LS1227 HDK. This is an initial test to make sure the chip works fine with HDK.

    Now its time for me to code  to use the chip for its original purpose.

    Thanks Guys for your kind support. Now we can close this issue.

    Best Regards,

    -Dinesh