View previous topic :: View next topic |
Author |
Message |
ofvy
Joined: 28 Jan 2006 Posts: 42
|
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu Jan 10, 2019 9:56 pm Post subject: |
|
|
Not sure if it's a bug or a feature, but the compiler keeps internal variables _sec, _min,..., _mont, _year not in order, instead squeezes other internals like ___READRAMPZ inbetween.
I can not see a good reason to interrupt the order of the date/time variables, especially as libs like datetime.lib rely on a certain order.
So I guess it is a compiler's problem of variable's placement, which seems even worse with XMega, where a whole lota bunch of internals is squeezed between time and date:
Code: | _SEC
_MIN
_HOUR
___READRAMPZ
_XMEGAREG
___LTMPAX
___DWTMPAX
___BTMPAX
___WTMPAX
___STMPAX
___DOUBLEA
___DOUBLEAX
_DAY
_MONTH
_YEAR |
Out of this reason the TO's example did not work for XMega, time was always reported '00:00:00'.
I did not try to fix the XMega issue, but a fix for the ATM1284P, where the internal var for its RAMPZ-register creates the trouble looks like that:
Open datetime.lib, create a copy before.
Look for [_MAKE_DT], and there for
Code: | sbiw zl, 3 ; Advance Pointer to _sec |
Replace with:
Code: | *#IF varexist("___READRAMPZ") AND _XMEGA=0
sbiw zl, 4 ; a fix for this occassion
*#ELSE
sbiw zl, 3 ; Advance Pointer to _sec
*#ENDIF |
Goto Menu --> Tools --> Lib Manager, mark datetime.lib and click the button 'Compile', close with 'OK'
After new compilation of the project it should work fine. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Jan 10, 2019 10:10 pm Post subject: |
|
|
This is a known problem. It has an easy fix too : dim your variables BEFORE the config clock. Or dim 1 dummy byte before CONFIG CLOCK.
The reason for the problem is that some internal variables are automatic added depending on the options. And the date time variables depend on their order.
Here is the official note :
rearranging memory order for usb support caused a bug in config clock : the date time bytes are not mapped after each other. This will cause a problem for $time function. A workaround is simple: dim a dummy or actual byte BEFORE the CONFIG CLOCK statement. _________________ Mark |
|
Back to top |
|
|
ofvy
Joined: 28 Jan 2006 Posts: 42
|
Posted: Thu Jan 10, 2019 10:52 pm Post subject: Time$ problem with ATMega1284p regfile |
|
|
Hi Albertsm.
Thank you very much for your quick response.
In the simulator it works now with ATmega1284P. Tomorrow I test it in an ATMega1284P in real time.
Best regards |
|
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
|
|