View previous topic :: View next topic |
Author |
Message |
sahu77
Joined: 08 Sep 2011 Posts: 202
|
save ROM ? |
Posted: Sun Jan 01, 2012 2:19 am |
|
|
i can save ROM ? when i use some MSG Defines on RAM .like this
Code: | /*****************************************************************************
MSG Defines on RAM
****************************************************************************/
#define msg_1[]= "NORMAL_VOLTAGE";
#define msg_2[]=" HIGH_VOLTAGE";
#define msg_3[]=" LOW_VOLTAGE";
#define msg_4[]=" CUT OFF";
|
save ROM .like this
Quote: | lcd_init(); // Always call this first.
lcd_putc("\f msg_2\n");
lcd_putc("msg_4");
|
in place of
Quote: | lcd_init(); // Always call this first.
lcd_putc("\f HIGH_VOLTAGE\n");
lcd_putc("CUT OFF");
|
what I'm doing right ?
if not ....pl help me _________________ sahu |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Sun Jan 01, 2012 3:25 am |
|
|
No.
The message still has to be stored in the ROM. #define is a _pre_ compile stage. Things 'defined', are replaced with their definitions, _before_ the compiler actually runs.
The messages have _got_ to be stored in ROM, or they will just be lost. If you declare a RAM variable, holding a message, the message is first stored in ROM, then copied to RAM when the chip boots, so you end up wasting RAM as well....
The syntax won't actually work anyway, but there would be no saving it it did.
Best Wishes |
|
|
sahu77
Joined: 08 Sep 2011 Posts: 202
|
|
Posted: Sun Jan 01, 2012 12:28 pm |
|
|
its means my method r wrong ? _________________ sahu |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Sun Jan 01, 2012 3:32 pm |
|
|
If you are only going to use the text once it has to be stored somewhere and it doesn't matter much how.
If you are going to use the same text in many locations you can have one copy in ROM and use it from those locations. But using a #define is not the way to do that.
Tell us more about your application. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
|