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 CCS Technical Support

CCS DS1629

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







CCS DS1629
PostPosted: Thu Aug 29, 2002 8:40 am     Reply with quote

Hello,

I look for the driver DS1629.C for CSS compilator.

Thank to send me the file.

Robert
___________________________
This message was ported from CCS's old forum
Original Post ID: 6718
hatanet



Joined: 08 Sep 2003
Posts: 9
Location: South Africa

View user's profile Send private message Visit poster's website

DS1629.C
PostPosted: Mon Oct 06, 2003 7:24 am     Reply with quote

Cool This is a baseline program I used to initialize, set & get DateTime & Alarms for the Dallas 1629 chip. The Date & Time are hard coded for demonstration purposes....

Goodluck still... after so long.


typedef struct {
int year;
int month; // 1-12 months
int date; // 1-31 day
int weekday; // 1=Sunday, 7=Saturday
int hours; // 24 hour mode
int minutes; // 0-59 mins
int seconds; // 0-59 secs
} DATE_TIME;

// I2C constants for selecting this device
#define I2C_SELECT_DS1629_READ 0x9F // 1001 1111
#define I2C_SELECT_DS1629_WRITE 0x9E // 1001 1110

void init_ds1629(void) {
output_high(I2C_SDA);
output_high(I2C_SCL);

// Set configuration register
i2c_start();
i2c_write(I2C_SELECT_DS1629_WRITE); // Select the ACCESS CONFIG register
i2c_write(0xAC); // continuous conversion mode, alarms off,
i2c_write(0x00); // disable oscillator output

i2c_stop();

// Start conversions
i2c_start();
i2c_write(I2C_SELECT_DS1629_WRITE);
i2c_write(0xEE);
i2c_stop();
}

// range -55'C to 125'C
float read_temp(void) {
signed int datah;
int datal;
float data;

i2c_start();
i2c_write(I2C_SELECT_DS1629_WRITE);
i2c_write(0xAA); // Read temperature
i2c_start();
i2c_write(I2C_SELECT_DS1629_READ);
datah = i2c_read(); // Receive and ACK
datal = i2c_read(0); // Receive and NACK
i2c_stop();

data = (float) datah;
if((datal&0x80)!=0) {
data += 0.5;
}
return(data);
}


// DS1629 Time & Temperature settings
void DS1629_set_dt(void)
{
// Time
i2c_start(); // initiate master start condition.
i2c_write(I2C_SELECT_DS1629_WRITE); // sends DS1629 address.
i2c_write(0xC0); // sends access clock potocol.
i2c_write(0x00); // sends access clock protocol.

i2c_write(0); // sets seconds & enables clock.
i2c_write(30); // sets clock minutes.
i2c_write(0x51); // sets clock hours and AM/PM clock mode.
i2c_write(2); // sets day of the week.
i2c_write(12); // sets date of the month.
i2c_write(11); // sets month of the year.
i2c_write(02); // sets the year.

// Temperature
i2c_start(); // initiate master start condition.
i2c_write(I2C_SELECT_DS1629_WRITE); // sends DS1629 address.
i2c_write(0xA1); // sends access TH protocol
i2c_write(0x32); // writes MSB of TH protocol (50 degrees C)
i2c_write(0x00); // writes LSB of TH protocol (50 degrees C)

i2c_stop(); // initiate master stop condition.
}
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