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

DS1302

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



Joined: 19 Oct 2011
Posts: 1

View user's profile Send private message

DS1302
PostPosted: Wed Oct 19, 2011 9:41 am     Reply with quote

Hi all, I tried to read a data from ds1302 but I failed to do so. Is there anything wrong in my code?
Code:

RST = 1;         
data_out(0x85);         //write to read hr register
temp1 = data_in();    //read in data
sec[2] = get_bcd(temp1);     //convert e data to bcd.. get from ds1302.c
RST = 0;

But I did it in burst read mode... it works.. can anyone explain this to me?
Thanks
Code:

RST = 1;      
data_out(0xBF);         //clock burst read
sec[0] = data_in();      //sec
sec[1] = data_in();      //min      
hr = data_in();      //hour
RST = 0;
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Oct 19, 2011 11:10 am     Reply with quote

Don't try to re-invent the wheel. The driver directory of your CCS compiler contains a tested driver for the DS1302.

An example program can be found in the examples directory: EX_RTCLK.C
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