View previous topic :: View next topic |
Author |
Message |
Thehon1985
Joined: 20 Feb 2007 Posts: 8
|
Posted: Fri Jun 15, 2007 9:26 pm Post subject: DateTime_Test1.bas confusion |
|
|
I am trying to learn to use a real time clock. Looking at DateTime_Test1.bas. and looking at this thread:
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=3620&highlight=rtc
I have some questions.
1. There are three subroutines (getdatetime, settime, and setdate) that are not called out in the body of the program. There is a comment statement saying that they are called out in datetime.lib, but that library is not used. Maybe it should be?? In the thread, Mark says that no librbay is needed. Or, maybe these subs are called out and I am too dumb to see it!
2. Apparently, when information is returned from the DS1307, it is in BCD format? So, that is why you need the makedec() statements in the getdatetime: sub. Is this right?
Sorry for the dumb questions. I am trying to learn.
Matt |
|
Back to top |
|
|
oe9vfj
Joined: 17 Jun 2004 Posts: 269 Location: Austria, Hard
|
Posted: Fri Jun 15, 2007 10:05 pm Post subject: |
|
|
Hi Matt,
I don't know the DS1307, but try to explain, what getdatetime, settime, and setdate is good for.
If you work with internal RTC with CONFIG CLOCK = SOFT the Date and time related variable _sec, _min, _hour, _day, _month and _year are updated by the clock-routine every second. If you use any Time - related command, this variables are used.
If you use an external Time-Source (RTC) like a DS1307 you have to update this variables or your RTC-Chip by yourself every time a Time - related command is used in your Program, BASCOM-AVR makes than a call to one of the three labels getdatetime, settime, and setdate
If you want to read or work with the actual time, BASCOM-AVR calls the label GetDateTime. Behind this Label you need code to read (for example) the actual date and time from the DS1307 and put the values in the above mentioned variables _sec ... _year. If your RTC-Chip delivers the values in the BCD-Format, you have to convert it into binary format first.
On the other way if you set the Date or time (for example with Date$ = '06/15/07' ) in your program, BASCOM-AVR fills the variables _Sec ... _Year with the according values and call the Label _SetDateTime.
At this point you have to transfer the Values from the time variables _Sec ... _Year to your external RTC-Chip. _________________ regards Josef
DOS - File System for BASCOM-AVR on http://members.aon.at/voegel |
|
Back to top |
|
|
Thehon1985
Joined: 20 Feb 2007 Posts: 8
|
Posted: Fri Jun 15, 2007 10:54 pm Post subject: |
|
|
Thank you. A few more questions please.
1. Do I need to use the "datetime.lib" or are the subroutines called out by Bascom without it? If Bascom calls them, what commands cause that?
2. I tried using the datetime.lib and got some errors:
Quote: |
Error 35 Line 1 3 parameters expected in datetime.lib
Error 46 Line 2 Assignment Error in datetime.lib
Error 1 Line 2 Unknown statement
|
What would cause this? The library I am using is 28 kb in size and is dated Nov. 15, 2005.
3. When I first tried to include that library file, I got the error File not found, so I found the library and copied it into the folder that my program was saved. I looked at the library file in the LIB subfolder in Bascom and found that it showed that it had been accessed today as well as datetime.lbx.
Do I always need to have a copy of the library files in the folder where I save my Bascom programs?
By the way, I am using Bascom 1.11.8.7 registered.
Thank you.
Matt |
|
Back to top |
|
|
|
|
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 You cannot attach files in this forum You cannot download files in this forum
|
|