Problems with Microcontroller Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you the Codes for Registered Members of this site only, at free service...Follow Me.

How to use ROM for storing DATA in MikroC Avoid Error Not Enough RAM and Strings problem (const truncated)

Most of the Microcontrolleres having limited RAM, For Avoiding the Errors Not Enough RAM and Strings problem (const truncated) .
You have to move the strings to ROM (FLASH program) memory, and there by save RAM.

In MikroC
if the string is declared as constant - compiler will move it to ROM
This is the way in which const truncated problem can be solved if
great number of strings was used that was located in RAM.

How we can impliment it in MikroC, see the example

First you declare the following
char text[15]; // this is stored in RAM
const char *mesg1="shibuvarkala1234"; // this is stored in ROM
const char *mesg2="CE Attingal"; // this is stored in ROM

here is the function for copying string before the usage ,
copy the following function to your code( Received from Mikroelecronica) :

// --- Copying strings from ROM to RAM
void strConstCpy(char *dest, const char *source) {
while(*source)
*dest++ = *source++ ;

*dest = 0 ;
}

you have to use the above function to access the strings stored in ROM,

strConstCpy(text,mesg1);
LCD_Out(1,1,text); // Now output is shibuvarkala1234

strConstCpy(text,mesg2);
LCD_Out(1,1,text); // Now output is CE Attingal

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Recent Comments

Popular Projects

Give Support

Give Support
Encourage Me through Comments

Microcontroller Projects

Total Pageviews