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.
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!");
int a = 200;
long result = 0;
Change it to
const int a = 200;
unsigned int result = 0;
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
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);
//......
void UART_Write_CText(const char *cptr)
{
char chr;
for ( ; chr = *cptr ; ++cptr ) UART1_Write(chr);
}