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 and TMP100 with I2C Communication have problem

Other Parts Discussed in Thread: TMP100, TMS320F28035

// FILE:	I2CComms.C
// TITLE:	DSP28035 (60Mhz)I2C test
//          Temperature Sensor TMP100 connected to GPIO33 (SCL) and GPIO32(SDA)
//			LED GPIO34 as life indicator 100 ms toggle
//			12 bit mode of TMP100, 1/16 degree celcius resolution
//			use watch window for variable "temperature" (type int; qvalue:8)
//###########################################################################
#include "DSP2803x_Device.h"
// TMP100 commands
#define TMP100_SLAVE 			0x48	// slave address TMP100 (ADDR0=ADDR1=0)
#define POINTER_TEMPERATURE 	0	
#define POINTER_CONFIGURATION 	1
#define POINTER_T_LOW 			2
#define POINTER_T_HIGH 			3
// external function prototypes
extern void InitSysCtrl(void);
extern void InitPieCtrl(void);
extern void InitPieVectTable(void);
extern void DSP28x_usDelay(long LoopCnt);
// Prototype statements for functions found within this file.
void Gpio_select(void);
void I2CA_Init(void);

long WaitTime = 110; // (9.3uS) @ 60Mhz TMS320F28035
int temperature;	// temperature = 2' Komplement of temparature (-128 ... +127 Celsius)
						// is an I8Q8 - Value 

void main(void)
{	
	InitSysCtrl();		// Basic Core Init from DSP2833x_SysCtrl.c
	DINT;			// Disable all interrupts	
	Gpio_select();	// GPIO9, GPIO11, GPIO34 and GPIO49 as output
					// to 4 LEDs at Peripheral Explorer	
	//	Initialize I2C
	I2CA_Init();

	// Send START, set pointer to Configuration register and set resolution to 12 bit
	I2caRegs.I2CCNT = 2;	
	I2caRegs.I2CDXR = POINTER_CONFIGURATION;
	I2caRegs.I2CMDR.all = 0x6E20;
	/*	Bit15 = 0;	no NACK in receiver mode
		Bit14 = 1;  FREE on emulation halt
		Bit13 = 1;  STT  generate START 
		Bit12 = 0;	reserved
		Bit11 = 1;  STP  generate STOP
		Bit10 = 1;  MST  master mode
		Bit9  = 1;  TRX  master - transmitter mode
		Bit8  = 0;	XA   7 bit address mode
		Bit7  = 0;  RM   nonrepeat mode, I2CCNT determines # of bytes
		Bit6  = 0;  DLB  no loopback mode
		Bit5  = 1;  IRS  I2C module enabled
		Bit4  = 0;  STB  no start byte mode
		Bit3  = 0;  FDF  no free data format
		Bit2-0: 0;  BC   8 bit per data byte	*/
	while(I2caRegs.I2CSTR.bit.XRDY == 0);		// wait until first byte is out
	I2caRegs.I2CDXR = 0x60;						// TMP100 in 12 bit mode (R1=R0=1)
	while(I2caRegs.I2CSTR.bit.SCD == 0);			// wait for STOP condition
	I2caRegs.I2CSTR.bit.SCD = 1;

	while(1)
	{    
			DSP28x_usDelay(WaitTime); 	// Delay time between STOP and START condition

			//	Send START and set pointer to temperature - register
			I2caRegs.I2CCNT 	= 1;				// pointer to temperature register
			I2caRegs.I2CDXR		= POINTER_TEMPERATURE;
			// Send start as master transmitter
	 		I2caRegs.I2CMDR.all = 0x6620;
			/*	Bit15 = 0;	no NACK in receiver mode
				Bit14 = 1;  FREE on emulation halt
				Bit13 = 1;  STT  generate START 
				Bit12 = 0;	reserved
				Bit11 = 0;  STP  not generate STOP
				Bit10 = 1;  MST  master mode
				Bit9  = 1;  TRX  master - transmitter mode
				Bit8  = 0;	XA   7 bit address mode
				Bit7  = 0;  RM   nonrepeat mode, I2CCNT determines # of bytes
				Bit6  = 1;  DLB  no loopback mode
				Bit5  = 1;  IRS  I2C module enabled
				Bit4  = 0;  STB  no start byte mode
				Bit3  = 0;  FDF  no free data format
				Bit2-0: 0;  BC   8 bit per data byte	*/
			while(I2caRegs.I2CSTR.bit.ARDY == 0);			// wait for access ready condition

			I2caRegs.I2CCNT		= 2;	// read 2 byte temperature 
			I2caRegs.I2CMDR.all = 0x6C20;
			/*	Bit15 = 0;	no NACK in receiver mode
				Bit14 = 1;  FREE on emulation halt
				Bit13 = 1;  STT  generate START 
				Bit12 = 0;	reserved
				Bit11 = 1;  STP  generate STOP
				Bit10 = 1;  MST  master mode
				Bit9  = 0;  TRX  master - receiver mode
				Bit8  = 0;	XA   7 bit address mode
				Bit7  = 0;  RM   nonrepeat mode, I2CCNT determines # of bytes
				Bit6  = 0;  DLB  no loopback mode
				Bit5  = 1;  IRS  I2C module enabled
				Bit4  = 0;  STB  no start byte mode
				Bit3  = 0;  FDF  no free data format
				Bit2-0: 0;  BC   8 bit per data byte	*/

			while(I2caRegs.I2CSTR.bit.RRDY == 0);	// wait for 1st byte
			temperature = I2caRegs.I2CDRR << 8;			// read upper 8 Bit (integers)
			// RRDY is automatically cleared by read of I2CDRR 
			while(I2caRegs.I2CSTR.bit.RRDY == 0);	// wait for 2nd byte
			temperature += I2caRegs.I2CDRR;				// read lower 8 Bit (fractions)
	}
} 

void Gpio_select(void)
{
	EALLOW;
	GpioCtrlRegs.GPAMUX1.all = 0;			// GPIO15 ... GPIO0 = General Puropse I/O
	GpioCtrlRegs.GPAMUX2.all = 0;			// GPIO31 ... GPIO16 = General Purpose I/O
	
	GpioCtrlRegs.GPBMUX1.all = 0;			// GPIO47 ... GPIO32 = General Purpose I/O
	GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1;	// GPIO32 = I2C - SDA
	GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1;	// GPIO33 = I2C - SCL

	GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0;    // Enable pull-up for GPIO32 (SDAA)
	GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0;	   // Enable pull-up for GPIO33 (SCLA)
	EDIS;
}  

void I2CA_Init(void)
{	
	I2caRegs.I2CMDR.bit.IRS = 0;	// Reset the I2C module
	// I2C slave address register
	I2caRegs.I2CSAR = TMP100_SLAVE;	
	// I2C 50Khz setting with TMS320F28035 60Mhz
	I2caRegs.I2CPSC.all = 5;									    
	I2caRegs.I2CCLKL = 95;
	I2caRegs.I2CCLKH = 95;						
	I2caRegs.I2CMDR.bit.IRS = 1;	// Take I2C out of reset
}

//===========================================================================
// End of SourceCode.
//===========================================================================
Hello every one,

            Now, I using TMS320F28035 and one TMP100 with I2C Communication(I2C clock = 50Khz, 8 bits transfer). Program is normal operation if  Wait time between STOP and START condition is above 10 uS. if less than 10uS. Prog is stop by check bit: "while(I2caRegs.I2CSTR.bit.ARDY == 0)". but In TMP100 datasheet, Bus Free time between STOP and START conndion : t_BUF = 600 nS.  I don't understand about "Wait time between STOP and START condition". How many  for waiting time for TMS28035?

(attach file).

Could you tell me about matter ?