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

time and date routines

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



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

time and date routines
PostPosted: Wed Nov 28, 2007 7:49 am     Reply with quote

Hi there.

Does any one perhaps have any useful date and time routines lying around somewhere. I am particularly looking for routines to convert a "seconds since date" to a D/M/Y H:M:S format and vice versa.

I want to use it with a RTC iButton DS1904. I have searched the forum/code lib and found some routines by Van Hauser (don't think its correct spelling) but it is not exactly what i had in mind. A long time ago i had some routines which i think is right but can't find them anymore, and don't know if it was from this forum either.

Can anybody please help?

Kind regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 28, 2007 3:20 pm     Reply with quote

See this Maxim appnote:
http://pdfserv.maxim-ic.com/en/an/AN517.pdf

Maxim is better than most companies on Appnotes. Usually, they will
have some useful appnote on how to use their chips. Here is the link
to their appnote page:
http://www.maxim-ic.com/appnotes10.cfm/filter/category
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

time and date routines
PostPosted: Wed Nov 28, 2007 11:48 pm     Reply with quote

Hi, thanx PCM Programmer i've just downloaded the app note, funny when i searched for RTC on maxim site yesterday i did not get (... or see...) this note even though it has RTC as one of its keywords... Anyway, it does seem like they have everything in there, but the code will roll over in 2038, by that time i will be quite old, and hopefully not working anymore... but would it be possible to change this date? i haven't read to code in depth yet so i'm asking you as professional.

I also did some homework of my own and found this:
http://www.picbasic.co.uk/forum/showthread.php?s=&threadid=250&perpage=15&pagenumber=1

it is everything i need in the wrong language, PBP. I started converting it to C but not being familiar with some of the functions, nor having a reference manual for that compiler it is going rather slow. Any translators willing to do the honor? or point me in the right direction?

Kind regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 29, 2007 12:46 am     Reply with quote

Quote:
so i'm asking you as professional.

I am still here at the company, working here at 10:40pm on a company
project. I'm not sure when I get to go home. I can't work on your
problem at the moment.
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

time and date routines
PostPosted: Thu Nov 29, 2007 5:15 am     Reply with quote

No prob, i understand we all have to work to stay alive...
I will try and find a PBP manual and have a look at the app note and see what i can cook up with that. Thanx for the effort so far Very Happy

Kind Regards
ckielstra



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

View user's profile Send private message

PostPosted: Thu Nov 29, 2007 8:45 am     Reply with quote

Quote:
but the code will roll over in 2038
A signed 32 bit integer as used in UNIX will roll over in 2038, but here the Maxim app note is using unsigned variables everywhere. A 32 bit unsigned counter would last 136 years and roll over in 2106. Who is wrong, me or Maxim?

It is not to difficult to change the Maxim app note to start counting in the year 2000, winning you another 30 years and simplifying the code as well.
Please note that in the Maxim application all unsigned longs are 32 bit integers, not 16 bit as in the CCS compiler.
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

PostPosted: Thu Nov 29, 2007 9:26 am     Reply with quote

Hi Ckielstra i think your right about the 136 year thing, that figure does sound very familiar. Thanx for pointing out the difference in the long interpretation.

I will see if i have energy tonight to start digesting information and writing some code...

Kind Regards
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