Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chayanforyou/63ca3d6e1a69a5b5b73de46f875f0cd6 to your computer and use it in GitHub Desktop.
Save chayanforyou/63ca3d6e1a69a5b5b73de46f875f0cd6 to your computer and use it in GitHub Desktop.

Reason for Not Enough ROM error!:

There are several reasons for this. Also, there are solutions to them. Sometimes, little precaution will help reduce your time consumption for a project. Otherwise, it may take hours, days, weeks even months to find the problem and solve it. Let’s find the reason and ways to solve that.

1. Using too much ASCII values

Convert the ASCII into a constant value. And print each digit one by one. Let’s see!

void Lcd_COut(char row, char col, const char *cptr)
{
    char chr = 0;             //first, it is used as empty string
    Lcd_Out(row, col, &chr);  //nothing to write but set position.
    for ( ; chr = *cptr ; ++cptr ) Lcd_Chr_CP(chr); //out in loop
}

Now use

Lcd_COut(1,1,"Hello World!");

2. Using wrong variable types

int a = 200;
long result = 0;

Change it to

const int a = 200;
unsigned int result = 0;

3. Using calculations in extended form

const int a = 200;
unsigned int result = 0;
//......
result = (255 + 50) * 3.5 * a;
//......

Refactor it

const int a = 200;
unsigned int result = 0;
//......
result = (255 + 50) * 35 / 10 * a;
//......

This will use less ROM instead of floating point calculation

4. Using Extra code lines

int value;
int txt[] = {0, 0, 0};
//......
value = 15;
txt[0] = value / 10 % 10;

EEPROM_Write(0, txt[0]);
//......

Refactor it

int value;
//......
value = 15;

EEPROM_Write(0, value/10%10);
//......

RAM to ROM copy for UART function:

void UART_Write_CText(const char *cptr)
{
    char chr;
    for ( ; chr = *cptr ; ++cptr ) UART1_Write(chr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment