CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

TCN75A One shot mode help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jspencer



Joined: 22 Dec 2003
Posts: 57
Location: Boise, ID USA

View user's profile Send private message

TCN75A One shot mode help
PostPosted: Wed Mar 08, 2006 8:32 pm     Reply with quote

I don't think that I am doing this correctly, so if someone can offer a little advice. I'm not exactly sure if I'm doing the one shot mode for the TCN75A correctly. Here is what I am doing currently. It works, but it is causing some issues with my external eeprom. I think that I am leaving it in a bad state or not finishing the transmission.

Code:
   

// TCN75 i2c addresses
#define TCN75_I2C_WRITE_ADDR  0x90
#define TCN75_I2C_READ_ADDR   0x91

// TCN75 register addresses
#define TCN75_TEMP_REG_ADDR    0x00
#define TCN75_CONFIG_REG_ADDR  0x01
#define TCN75_THYST_REG_ADDR   0x02
#define TCN75_TSET_REG_ADDR    0x03

#define TCN75_SHUTDOWN_MODE    0x01
#define TCN75_ONE_SHOT_MODE    0x81
#define TCN75_CONTINUOUS_MODE  0x00

// put in shutdown mode so that we can access one shot mode.

   i2c_start();
   i2c_write(TCN75_I2C_WRITE_ADDR);
   i2c_write(TCN75_CONFIG_REG_ADDR);
   i2c_write(TCN75_SHUTDOWN_MODE);
   i2c_stop();

// now access one shot mode and read the temperature

   i2c_start();
   i2c_write(TCN75_I2C_WRITE_ADDR);
   i2c_write(TCN75_CONFIG_REG_ADDR);
   i2c_write(TCN75_ONE_SHOT_MODE);

   i2c_start();
   i2c_write(TCN75_I2C_WRITE_ADDR);
   i2c_write(TCN75_TEMP_REG_ADDR);
   i2c_start();   
   i2c_write(TCN75_I2C_READ_ADDR);
   msb = i2c_read();
   lsb = i2c_read(0);
   i2c_stop();



Appreciate the extra set of eyes.

jspencer
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 08, 2006 9:34 pm     Reply with quote

You're missing the stop bit after the config write. Add the line
shown in bold below:
Quote:
i2c_start();
i2c_write(TCN75_I2C_WRITE_ADDR);
i2c_write(TCN75_CONFIG_REG_ADDR);
i2c_write(TCN75_ONE_SHOT_MODE);
i2c_stop(); // Add this line

i2c_start();
i2c_write(TCN75_I2C_WRITE_ADDR);
i2c_write(TCN75_TEMP_REG_ADDR);
i2c_start();
i2c_write(TCN75_I2C_READ_ADDR);
msb = i2c_read();
lsb = i2c_read(0);
i2c_stop();
jspencer



Joined: 22 Dec 2003
Posts: 57
Location: Boise, ID USA

View user's profile Send private message

PostPosted: Thu Mar 09, 2006 9:40 am     Reply with quote

Thanks for the extra set of eyes PCM.

jspencer
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group