Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SW problem on TC74 temperature sensor (PICDEM2 plus board)

Status
Not open for further replies.

joseMiguel

Member level 5
Joined
Jan 10, 2011
Messages
86
Helped
10
Reputation
20
Reaction score
10
Trophy points
1,288
Location
Montpellier FRANCE
Activity points
1,967
Hi, i just have SW problems to run the TC74 with the I2C libraries.

Code:
void main()
{
	int i;
	TRISB=0x0;
  	OpenI2C(MASTER, SLEW_ON);// Initialize I2C module
	init_LCD();

    SSPADD = 9;              //400kHz Baud clock(9) @16MHz
                           //100kHz Baud clock(39) @16MHz
                           
	// generates a start condition
	while(1)
	{
	

	
		
	Delay1KTCYx(10);
	StartI2C();                     // initiate START condition
	WriteI2C( 0x9A );
	WriteI2C( 0x00 );
	//StopI2C();


	StartI2C();                     // initiate START condition
	WriteI2C( 0x9B );
	data = ReadI2C();
	
	//NotAckI2C();
	StopI2C();

	fahr = (9*(long)data);
	fahr = fahr/5;
	fahr = fahr +32;

	for(i=0; i<10; i++)
	Delay10KTCYx(100);
	//floatToStr(fahr);
	//chaintxt(str,0);
	}
	
	
}

thank you
JoseMiguel
 

Code:
#define		TC74_READ	   0x9B
#define		TC74_WRITE	   0x9A   

//////////////////////////////////////////////////////////////
void tc74_write(unsigned char reg,unsigned char val)
{
i2c_start(); 
i2c_write(TC74_WRITE);    
i2c_write(reg);  
i2c_write(val); 
i2c_stop(); 
}  
//////////////////////////////////////////////////////////////
void tc74_read(unsigned char reg,unsigned char *value)
{
i2c_start();
i2c_write(TC74_WRITE);
i2c_write(reg); 
i2c_repStart();
i2c_write(TC74_READ);
*value=i2c_read(0);  //ACK 
i2c_stop();   
}

START|TC74_WRITE|ACK|reg|ACK|repstart|TC74_READ|ACK|read data|NACK|STOP

 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top