AnsweredHot!Precharge __DATE__ on EEPROM

Page: 123 > Showing page 1 of 3
Author
alex mar
New Member
  • Total Posts : 22
  • Reward points : 0
  • Joined: 2017/05/25 04:12:03
  • Location: 0
  • Status: offline
2017/07/13 06:51:32 (permalink)
0

Precharge __DATE__ on EEPROM

Hi, I'm trying make of the title says, use the macro __DATE__ to get the actual compiling time and write it in the EEprom with the macro __EEPROM_DATA. But it doesn't works
 
Any help?
Thanks!
#1
du00000001
Just Some Member
  • Total Posts : 1411
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 06:58:46 (permalink)
+3 (3)
"Doesn't work" means exactly what?
#2
Gort2015
Klaatu Barada Nikto
  • Total Posts : 1541
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 07:00:26 (permalink)
0
That is not possible.
Your program is not aware of how long it took to compile your source code.
 
If that is what you mean?
#3
alex mar
New Member
  • Total Posts : 22
  • Reward points : 0
  • Joined: 2017/05/25 04:12:03
  • Location: 0
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 07:15:09 (permalink)
0
Sorry,
 
I want store in eeprom the actual date (july 13 2017), not the compiling time. 
 
if I write: 
 
#define BUILD_YEAR_CH0 __DATE__[8]
..
..
..
..
__EEPROM_DATA (BUILD_YEAR_CH0,BUILD_YEAR_CH2,BUILD_YEAR_CH3,0xFF,0xFF,0xFF,0xFF,0x10); //addr 0xF8 - 0xFF

 
Get this error:
 
Main.c:214: error: (875) bad character constant in expression
Main.c:214: error: (876) syntax error
Main.c:215: error: (875) bad character constant in expression
Main.c:215: error: (876) syntax error
 
 
post edited by alex mar - 2017/07/13 07:19:14
#4
CinziaG
morite
  • Total Posts : 3140
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 08:02:54 (permalink)
0
It isn't working in C30 as well...
I never considered that but, oh well, need a different approach

get my books!
lulu.com search.ep?keyWords=greggio&type=
 
#5
rodims
Super Member
  • Total Posts : 932
  • Reward points : 0
  • Joined: 2009/02/10 11:08:59
  • Location: 51.9627, 7.6262
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 08:16:27 (permalink)
+1 (1)
You did not specify your PIC, nor your compiler, nor did you show your defines
 
Try
__EEPROM_DATA (0,1,2,3);
What do you see ?
 
alexI want store in eeprom the actual date (july 13 2017), not the compiling time.

 
You seem to make a difference between "time" and "date" ?
You are aware of __DATE__ and __TIME__ ?
This is the actual date/time of compilation. Not sure what you really want. 
#6
alex mar
New Member
  • Total Posts : 22
  • Reward points : 0
  • Joined: 2017/05/25 04:12:03
  • Location: 0
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 08:32:23 (permalink)
0
Hi, 
PIC16F1788, XC8 compiler in free mode
__DATE__ returns date "Jul 13 2017", I need store this value in EEPROM, because in my work we manufacture devices and we need trace it.
 
Other solution it's make a function that only run on the first start, and write in the eeprom this values, using this statement unsigned char compileDate[]=__DATE__;
 
Thanks!
#7
rodims
Super Member
  • Total Posts : 932
  • Reward points : 0
  • Joined: 2009/02/10 11:08:59
  • Location: 51.9627, 7.6262
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 08:49:26 (permalink)
+2 (2)
Should I interprete your answer in the sense that
__EEPROM_DATA (0,1,2,3);
works perfectly ok ?
 

Other solution it's make a function that only run on the first start, and write in the eeprom this values, using this statement unsigned char compileDate[]=__DATE__;

Why not.  The question is how you "use" the data later on. If you simply display it somehow from within your app, then there is no need to save it in the EEPROM. 

 
#8
alex mar
New Member
  • Total Posts : 22
  • Reward points : 0
  • Joined: 2017/05/25 04:12:03
  • Location: 0
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 09:00:57 (permalink)
0
rodims
Should I interprete your answer in the sense that
__EEPROM_DATA (0,1,2,3);
works perfectly ok ?
 

Other solution it's make a function that only run on the first start, and write in the eeprom this values, using this statement unsigned char compileDate[]=__DATE__;

Why not.  The question is how you "use" the data later on. If you simply display it somehow from within your app, then there is no need to save it in the EEPROM. 
 


if in the future I need know the program version, but I suppose if I define a variable with value __DATA__, should be work
 
 Thanks!
post edited by alex mar - 2017/07/13 09:04:42
#9
Gort2015
Klaatu Barada Nikto
  • Total Posts : 1541
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 09:10:35 (permalink)
+1 (1)
Goes something like this.   If I remember it has to be in groups of eight if you want that written at startup.
 
__EEPROM_DATA('G','O','R','T','2','0','1','5');


These are the proto's.
 
char eeprom_write(int Address, char C);  //not sure if the error return is char or int
char eeprom_read(int Address);


#10
Gort2015
Klaatu Barada Nikto
  • Total Posts : 1541
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 09:30:31 (permalink)
0
char x=eeprom_read(0); // 'G'
x=eeprom_read(1); // 'O'
x=eeprom_read(2); // 'R'
x=eeprom_read(3); // 'T'
 
 
#11
Gort2015
Klaatu Barada Nikto
  • Total Posts : 1541
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 09:30:31 (permalink)
0
char x=eeprom_read(0); // 'G'
x=eeprom_read(1); // 'O'
x=eeprom_read(2); // 'R'
x=eeprom_read(3); // 'T'
 
 
#12
1and0
Access is Denied
  • Total Posts : 7192
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 09:49:32 (permalink)
+1 (1)
alex mar
Hi, I'm trying make of the title says, use the macro __DATE__ to get the actual compiling time and write it in the EEprom with the macro __EEPROM_DATA. But it doesn't works
...
PIC16F1788, XC8 compiler in free mode

Try this
eeprom uint8_t date[] = {__DATE__};   // "Jul 13 2017"

 
<edit> Actually the type should be char as it's a string literal:
eeprom char date[] = __DATE__;  // "Jul 13 2017"

post edited by 1and0 - 2017/07/13 10:19:17
#13
CinziaG
morite
  • Total Posts : 3140
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 10:06:28 (permalink)
0
1and0
 

Try this
eeprom uint8_t date[] = {__DATE__};   // "Jul 13 2017"





This works, but I would not like it wink
 
How to extract single chars from it?

get my books!
lulu.com search.ep?keyWords=greggio&type=
 
#14
1and0
Access is Denied
  • Total Posts : 7192
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 10:15:40 (permalink)
+1 (1)
CinziaG
 
This works, but I would not like it 
How to extract single chars from it?

With
 char x = date[0]; // 'J'

 
 
#15
CinziaG
morite
  • Total Posts : 3140
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 10:18:24 (permalink)
0
No Smile, I meant how I would I put only some chars from DATE into EEprom, something like:
 
eeprom uint8_t mydata[] = {'V','e','r',' ',__DATE__[0],__DATE__[1] }; 
(which I suppose was what OP asked for, more or less)

get my books!
lulu.com search.ep?keyWords=greggio&type=
 
#16
1and0
Access is Denied
  • Total Posts : 7192
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 10:23:02 (permalink) ☄ Helpfulby alex mar 2017/07/13 23:50:45
+1 (1)
To me, OP just wants to store the compile date "mmm dd yyyy" into the built-in eeprom at compile time.
 
#17
CinziaG
morite
  • Total Posts : 3140
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 10:26:05 (permalink)
0
Well, whatever he wants Smile, I find it strange that your example does work while when I try to store only one or 2 chars I get a "cannot resolve expression at compile time" (or alike).
 
(well, I only tested it quickly...)

get my books!
lulu.com search.ep?keyWords=greggio&type=
 
#18
1and0
Access is Denied
  • Total Posts : 7192
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 10:31:14 (permalink)
+1 (1)
CinziaG
... while when I try to store only one or 2 chars I get a "cannot resolve expression at compile time" (or alike).

What you wanted might require more macros. I'll have to think about that. I don't think __DATE__[0] would work.
 
<edit> Don't think it can be done because the C preprocessor cannot perform such manipulation.
 
post edited by 1and0 - 2017/07/13 10:59:49
#19
CinziaG
morite
  • Total Posts : 3140
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline
Re: Precharge __DATE__ on EEPROM 2017/07/13 10:38:24 (permalink)
+1 (1)
Ok, no well don't worry about it - but thanks Smile!
I actually would not put that Date into EEprom, does not make much sense in my opinion.

get my books!
lulu.com search.ep?keyWords=greggio&type=
 
#20
Page: 123 > Showing page 1 of 3
Jump to:
© 2017 APG vNext Commercial Version 4.5