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.

TMS320F28386D: Sending a Stop Sequence after Receiving NACK (Master Write)

Part Number: TMS320F28386D
Other Parts Discussed in Thread: C2000WARE

Hello,

    I am working with the I2C communication with my TMS320F28386D and I am trying to achieve the following behavior.

I want the I2C module to send a Stop sequence after a message that is NACK'ed.  At the moment my code only sends

stop sequences for messages that write out all of their bytes successfully.  It is important, to the slave device that I am 

writing to, that the stop sequence happens after every message so that it will recognize my retries.

    In the TRM it says the following about the I2CMDR.STP register, "... STP has been set by the device to generate a STOP 

condition when the internal data counter of the I2C module counts down to 0".  And in the TRM it also says this about the 

I2CNT Register, "The value written to I2CCNT is copied to an internal data counter.  The internal data counter is decremented

by 1 for each byte transferred ... If a STOP condition is requested in the master mode (STP on I2CMDR), the I2C module terminates

the transfer with a STOP condition when the countdown is complete..." I try to leverage these points to generate a stop condition in my 

state machine after a NACK.  Any help is greatly appreciated, Thank You. I've attached a snippet of my code below.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
switch(Substate)
{
case -1:
{ //NACK Detected
EALLOW;
I2caRegs->I2CSTR.bit.SCD = 1;
I2caRegs->I2CMDR.bit.STP = 1; //Enabling the Stop condition upon CNT = 0;
I2caRegs->I2CCNT = 0; //Trying to trick the I2C module that I have sent all of its bytes
EDIS;
if(masterWriteRetryCtr < masterWriteRetryLim)
{
//Code For Retry
...
//End Code For Retry
}
else
{
Substate = 0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX