Greetings pros !
I have a small problem regarding MikroC and pic18f4510.
In my program i use a lot of debug messages which i am sending to LCD or to UART. The problem is that the compiler puts the static messages in pics RAM not in FLASH
Well , the messages are static so why would it put it in RAM i have no idea.
Does any one have any suggestions about the topic ? How do i put the static messages in FLASH instead of RAM ?
Thanks
Need help to store static stings in flahs not in ram !
-
- Posts: 34
- Joined: 21 Mar 2009 15:13
- Location: Israel
-
- Posts: 10
- Joined: 24 Jan 2010 18:59
Re: Need help to store static stings in flahs not in ram !
hiCyberArtem wrote:Greetings pros !
I have a small problem regarding MikroC and pic18f4510.
In my program i use a lot of debug messages which i am sending to LCD or to UART. The problem is that the compiler puts the static messages in pics RAM not in FLASH
Well , the messages are static so why would it put it in RAM i have no idea.
Does any one have any suggestions about the topic ? How do i put the static messages in FLASH instead of RAM ?
Thanks
usually when u wanna save specific message that wont change all over the program u need to use static before the letters..for example if u wanna save "hello: at ur program u can save it in array like this :
const int save[5]={'h','e','l','l','o'};
when u do this ur message "hello" will be saved in the program memory not at ram.
or u can use writing in eeprom of the pic ..but its limited place to save texts...
try this..and hope this will work with u..good luck..
- mileta.miletic
- mikroElektronika team
- Posts: 493
- Joined: 05 Jun 2009 14:46
- Location: Belgrade, Serbia
- Contact:
Re: Need help to store static stings in flahs not in ram !
Hi,
Put string in flash by declaring it as constant, then in place of call copy it to the RAM by using CopyConst2Ram function defined bellow:
Put string in flash by declaring it as constant, then in place of call copy it to the RAM by using CopyConst2Ram function defined bellow:
Code: Select all
const char part1[] = "some text";
char msg[16]; //declare array
// copy const to ram string
char * CopyConst2Ram(char * dest, const char * src){
char * d ;
d = dest;
for(;*dest++ = *src++;)
;
return d;
}
void main(){
...
Lcd_Out(1,1,CopyConst2Ram(msg,part1));
...
}
Regards,
Mileta
Mileta
-
- Posts: 2780
- Joined: 25 Dec 2008 15:22
- Location: Scotland
Re: Need help to store static stings in flahs not in ram !
Hi Mileta,mileta.miletic wrote:Code: Select all
char msg[16]; //declare array
thank you for the professional layout. would the RAM array storage not need to be 17 for using the given function with 16 character displays.
Code: Select all
char msg[17]; //declare array
Mince
Best Regards
Mince
Mince
-
- Posts: 34
- Joined: 21 Mar 2009 15:13
- Location: Israel
Re: Need help to store static stings in flahs not in ram !
Thanks guys ,the problem solved. Your assistance is much appreciated
- mileta.miletic
- mikroElektronika team
- Posts: 493
- Joined: 05 Jun 2009 14:46
- Location: Belgrade, Serbia
- Contact:
Re: Need help to store static stings in flahs not in ram !
Thanks Mince.Mince-n-Tatties wrote:Code: Select all
char msg[17]; //declare array
Regards,
Mileta
Mileta