View previous topic :: View next topic |
Author |
Message |
Greece2001
Joined: 06 Apr 2009 Posts: 57
|
Posted: Tue Apr 07, 2009 12:26 pm Post subject: Confusing Date ? |
|
|
Hi, I'm new to BASCOM and the" Date" command is absolutely confusing me.
Though I (think) I have configured everything correctly, Day and Month are not in the correct order.
Here are parts oy the code :
Config Date = DMY , Separator = . ' day.month.year format
Config Clock = User ' I'm Using the DS1307, works fine ...
dim StrTime As String * 8
Dim BWeekday As Byte
Dim StrWeekday As String * 10
Dim StrDate As String * 8
Dim Weekday As Byte
print #1 , "Date Test" '
_day = 07 ' set the internal vars to 7th of April 2009, today
_month = 04
_year = 09
print #1 , "Date$ = " ; Date$ ' This prints Date$ = 07/04/09 -> Date is okay, but Separator is wrong !
Bweekday = Dayofweek(_day)
print #1 , "_day=" ; _day ' This prints _day=4-> that should be 7 !
print #1 , "Bweekday:" ; bweekday ' This prints Bweekday:5 -> wrong !
Strweekday = Lookupstr(bweekday , Weekdays)
Strdate = Date(_day)
print #1 , "StrDate : " ; StrDate ' this prints StrDate : 04.07.09 -> Separator are okay, but Day / Month are in wrong order !
Print #1 , "Weekday-Number of Day=" ; _day ; " Month=" ; _month ; " Year=" ; _year ; " is " ; Bweekday ; " (" ; Date(_day) ; ") = " ; Strweekday ' -> Day / Month are wrong again
print #1 , "Date$ = " ; Date$ ' this prints Date$ = 7/04/09 -> Day / Month are okay, but Separator is wrong ...
By now I read all the examples, help-files, searched the forum for two days and either I'm too stupid to find my mistake or to understand how to use the Date and Date$ command or there is something else wrong.
So, please throw all you knowledge at me !
regards,
Greece2001 |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Tue Apr 07, 2009 4:08 pm Post subject: |
|
|
Hi Greece,
What version of Bascom are you using and what type of Avr.
It's difficult to reproduce the problem with the incomplete code. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
Greece2001
Joined: 06 Apr 2009 Posts: 57
|
Posted: Wed Apr 08, 2009 7:39 am Post subject: |
|
|
It is the 1.11.9.0 Demo I got from a friend, the µC ist a mega128.
regards,
Greece2001 |
|
Back to top |
|
|
oe9vfj
Joined: 17 Jun 2004 Posts: 269 Location: Austria, Hard
|
Posted: Wed Apr 08, 2009 8:35 am Post subject: |
|
|
I tested your code and it works all well. I got the estimated result.
May be your stack-settings are to low. _________________ regards Josef
DOS - File System for BASCOM-AVR on http://members.aon.at/voegel |
|
Back to top |
|
|
Greece2001
Joined: 06 Apr 2009 Posts: 57
|
Posted: Wed Apr 08, 2009 9:22 am Post subject: |
|
|
Strange, very strange. Here the definition part of the program and I reduced the program to the date / time - thing, so much of the config-stuff could be left out. The RTC is running fine, keeping time and everthing.
Code: | $regfile = "m128def.dat" ' used device Mega128
$lib "ds1307clock.lib"
$lib "i2c_twi.lbx" ' we do not use software emulated I2C but the TWI
$hwstack = 30 ' stack depth
$swstack = 30
$framesize = 40 'default use 40 for the frame space
$crystal = 8000000
Config Timer1 = Timer , Prescale = 1024
Config Timer3 = Timer , Prescale = 256
Config Scl = Portd.0
Config Sda = Portd.1
Config 1wire = Porte.2
$baud1 = 19200
Config Com2 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "com2:" For Binary As #1
Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Portb.1 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portb.4 , Rs = Portb.5
Config Lcd = 20 * 4
Config Adc = Single , Prescaler = Auto , Reference = Internal ' config, Internal (2.56V) Vref is used
Config Date = DMY , Separator = .
Config Clock = User |
|
|
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
|
|