EmbeddedRelated.com
Forums

__TIME__ unix time stamp assembly IAR current time at compile

Started by tonyp1454 June 2, 2011
How would I use __TIME__ to set my 48bit counter at time of compiling/flashing the msp430

Keep in mind I'm a assembler programmer.

I'm reserving 3 registers or maybe 6bytes of RAM for my counter,
as 32bit could result in the Y2K38 problem.

somethink like this:
mov.w (utime>>16),R15 ; Upper Unix time 16bits
mov.w (utime&FFh),R14 ; Lower Unix time 16bits

Beginning Microcontrollers with the MSP430

If I want null terminated ascii string I can use
dc8 __TIME__

But DATE gives me interger

DATE 1 Current second (059).
DATE 2 Current minute (059).
DATE 3 Current hour (023).
DATE 4 Current day (131).
DATE 5 Current month (112).
DATE 6 Current year MOD 100 (1998 98, 2000 00, 2002 02).

Example: dc32 DATE 1 + DATE 2 *60 + DATE 3 *3600

The month I probably would need to set up a table with number of days
Year I'm not sure if I should make it 365.25 or calc leapyears.

I'm just curious as to how you would use "time at compilation" other than to just display it.

Lloyd

--- In m..., "tonyp1454" wrote:
>
> How would I use __TIME__ to set my 48bit counter at time of compiling/flashing the msp430
>
> Keep in mind I'm a assembler programmer.
>
> I'm reserving 3 registers or maybe 6bytes of RAM for my counter,
> as 32bit could result in the Y2K38 problem.
>
> somethink like this:
> mov.w (utime>>16),R15 ; Upper Unix time 16bits
> mov.w (utime&FFh),R14 ; Lower Unix time 16bits
>

--- In m..., "lslonim2" wrote:
>
> I'm just curious as to how you would use "time at compilation" other than to just display it.
Software based RTC (real Time Clock)

If the deviced is battery powered when I program it,
it will keep ticking away after I program it.

For Data Loggers etc

here is a snippet
ORG 0200h
time dc8 DATE 6, DATE 5, DATE 4, DATE 3, DATE 2, DATE 1
...

add.b #1,&time+3 ; hours
cmp.b #24,&time+3 ; 0-23 hour range
jlo Skipclock
mov.b #0,&time+3

add.b #1,&time+2 ; days
mov.b &time+1,R10 ; set R10 to month
add.w #daycnt,R10 ; add 31/30 pointer
bit.b #11b,&time ; leapyear test 04,08,12 etc
jnz Noleap
cmp.b #00,&time ; 2100,2200,2300 not a leapyear
jeq Noleap
cmp.b #2,&time+1 ; is it feb?
jne Noleap
sub.w #2, R10 ; allow 29 days
Noleap cmp.b @R10,&time+2 ; 1-30/31 day range
jlo Skipclock
mov.b #1,&time+2 ; reset days
and to get the timestamp data out, I just do a mem dump with this
http://processors.wiki.ti.com/index.php/MSP430_Flasher_-_Command_Line_Programmer