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

DS1631 error

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



Joined: 17 Feb 2004
Posts: 23

View user's profile Send private message

DS1631 error
PostPosted: Sat Mar 20, 2004 4:35 am     Reply with quote

Hi,

I am using DS1631 driver from CCS. However, i always get t = 1E1E. I have check the datasheet from maxim-ic.com, it shows that the LSB must be always zero. Can you point me out where i did wrongly?

Code:
#include "DS1631.C"
#include <math.h>

void main() {
   int16 t;

   init_temp();

   while(1) {

      t = read_full_temp();
      printf("\n\r t: %4LX \n\r", t);
      getc();
   }

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 20, 2004 2:02 pm     Reply with quote

Quote:
I am using DS1631 driver from CCS. However, i always get
t = 1E1E. I have check the datasheet from maxim-ic.com, it shows that
the LSB must be always zero. Can you point me out where i did wrongly?

You need to read the CCS driver file and the DS1631 data sheet more
closely. The CCS driver, DS1631.C, says that it returns the temperature
in degrees Fahrenheit, in hundredths. This means it returns the
degrees x 100.

For example, you got 0x1E1E. Convert that to decimal. It's 7710.
Divide that by 100. You get 77.1 degrees Fahrenheit. That's about
25 degrees Celsius.

Also, note that the CCS driver puts the Ds1631 in 12-bit mode.
This is explained in the data sheet, with a sample chart for that
mode in Table 4.

In your post, you implied that you wanted to see the raw data from
the DS1631. To do that, you need to modify the following routine
in the CCS driver. Comment out the conversion code, and add 1
line of code, as shown below.
Code:
signed long read_full_temp() {
   signed int  datah, datal;
   signed long data;

   i2c_start();
   i2c_write(0x90);
   i2c_write(0xaa);
   i2c_start();
   i2c_write(0x91);
   datah=i2c_read();
   datal=i2c_read(0);
   i2c_stop();

// Comment out the conversion to degrees Fahrenheit x 100.
// Now this function will return the raw data.
//   data=(long)datah*100;     
//   data=data+(((datal >> 4 )*(long)50)/16);
//   data=data*9;
//   data = (data / 5) + 3200;
//   return(data);

return( ((long)datah << 8) | (long)datal);

}
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