Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

error dateline

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> AVR-DOS
View previous topic :: View next topic  
Author Message
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 837
Location: France

france.gif
PostPosted: Sat Jun 08, 2019 10:44 am    Post subject: error dateline Reply with quote

Hello
I have been using AVR-DOS with Hkipnik routines for a long time
included in its programs to drive displays with SD card readers, I never had a problem.
I want to change the display but continue to use AVR-DOS
I started the step-by-step writing of the file reading and writing program
and everything is going well until I want to add my date and time routines (as a remark in the program)



I then have a "label datetime not found" error [img]

Code:

'programmateur Arduino STK500/V2    115200 baud 200 timeout et port visible dans diagnostic
' Arduino mega 2560
' SCK= PB1 (20) {52}
' Miso=PB3 (22){50}
' mosi=PB2 (21) {51}
' ss =PB0 (19) {53}
'I Use A Lot Of Part From
'Hkipnik@aol.com
'---------------------------------------------------------------------------------------------------------------------------------------------------------------
$regfile = "m2560def.dat"
$crystal = 16000000
$hwstack = 250
$swstack = 250
$framesize = 430
Config Submode = New


'---les config*****************************************************************************
Config Com1 = 38400 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Com2 = 57600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Serialin1 = Buffered , Size = 20
Config Serialout1 = Buffered , Size = 20
$lib "i2c_twi.lbx"       ' we do not use software emulated I2C but the TWI
' Configure the SCL and SDA pins
Config Sda = Portd.1
Config Scl = Portd.0
Config Twi = 400000                                         '100000
'(
'------------les config date &time------------------------------------------------------
Config Clock = User       ' we use I2C for the clock
Config Date = Dmy , Separator = /
_year = 19
_month = 6
_day = 8
_hour = 11
_min = 0
_sec = 30
')
'*******************************************************************************
Const Ds3231r = &B11010001       'Ds3231 is very similar to DS1307 but it include a precise crystal
Const Ds3231w = &B11010000
Const Sd_card = 1                                           'with SD Card = 1 -- without SD Card = 0
'*******************************************************************************
$include "I2C-DS3231.inc"
$include "sd-card_routines-JP.inc"
'*******************************************************************************
$include "Config_MMCSD_HC.bas"
Call Sdcard_initialize()
'****Variable to use with AVR-dos****************************************************
Dim Ff As Byte       'freefile)
Dim Stdir As String * 35       'name of directory or other sentence to write
Dim Lenstring As Word

'****variable used here ************************************************************
Dim Sentence As String * 60
Dim Help_str As String * 10



'write a sentence in a file named fileone*****************
Sentence = "hello word"
If Stdir = "" Then
   Stdir = "fileone"
   Stdir = Stdir + ".TXT"
End If

Ff = Freefile()
Open Stdir For Output As #ff       'or append if you need to append some text
Write #ff , Sentence
Close #ff
Waitms 100
Print "Write stdir : " ; Stdir
Print "write sentence : " ; Sentence

Waitms 200

'Read a sentence in the same  file**********************
Stdir = "fileone"
Stdir = Stdir + ".TXT"
Ff = Freefile()
Open Stdir For Input As #ff
Do
   If Filelen(stdir) > 0 Then       'un fichier anniv existe
      Lineinput #ff , Sentence       ' read a line line input is used to read a line of text from a file
      If Len(sentence) > 0 Then
         If Left(sentence , 1 ) = Chr(34) Then       ' delete the of "
            Delchar Sentence , 1
         End If
         If Right(sentence , 1) = Chr(34) Then      ' delete the of "
            Lenstring = Len(sentence)
            Delchar Sentence , Lenstring
         End If

      End If
  End If
Loop Until Eof(#ff) <> 0       'The EOF() function returns a non-zero number when the end of the file is reached
Close #ff       'This way we know that there is no more data we can read
Print "read stdir : " ; Stdir
Print "read sentence : " ; Sentence
Waitms 200

End
 


many thanks for your help

JP Crying or Very sad
I add all programs used

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1520
Location: Basel, Switzerland

switzerland.gif
PostPosted: Sat Jun 08, 2019 11:41 am    Post subject: Reply with quote

Hi,

Have a look in the help text for config clock:

Quote:
When you choose the USER option, only the internal variables are created (like _sec , _min , _hour....).

With the USER option you need to write the clock code yourself (so the USER need to update for example the System Second or Secofday).

This means the one second clock must be generated by a "USER" source like a Timer which use the internal clock or an XTAL depending on the Xtal configuration.

There are so called "AVR Timer Calculator" online available where you input the clock frequency from xtal, which Timer you use (8 or 16 Bit) and the period you want to achieve (like 1 second or 1000ms) than it will give you number which you need to configure the timer.

You also configure the interrupt of the timer and then the program will jump to the timer interrupt routine where you can set the new system second.



Config Clock = User 'Use USER to write/use your own code

You also need to include the following labels with config clock = user:

Getdatetime:
'called when date or time is read
Return

Setdate:
'called when date$ is set
Return

Settime:
'scanned when time$ is set
Return



Regards
Ian Dobson

_________________
Home of AVRTimer, the Bascom timer value calculator.
http://www.planet-ian.com

Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 837
Location: France

france.gif
PostPosted: Sat Jun 08, 2019 2:21 pm    Post subject: error datetime [solved] Reply with quote

thanks you Ian,

I did the routines for time, date in a .Inc file
But I forgot to call them. It is a little bit tricky

I just would like to check if my avr-dos routine was working
but because I put the line config clock=User, i need to put the line : call getdatetime()

It is never said in the help or I did'nt see that you need it nor in the avr-dos documents


Wink
JP

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> AVR-DOS All times are GMT + 1 Hour
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
You cannot attach files in this forum
You cannot download files in this forum