I cannot get rid of this warning. All the documents I have read do not help at all. ( these include Keil forum search, Keil help function, the 8051 "bible", google e.t.c).
void halLcdWriteLine(uint8 line, const char* text) { BYTE sendBuffer[50]; UINT8 i, j; char c; if (text == NULL) return; i = 0; sendBuffer[i++] = LCD_ADDR; sendBuffer[i++] = REG_SEL_0; sendBuffer[i++] = ((line == HAL_LCD_LINE_1) ? LINE1_ADDR : LINE2_ADDR); smbSend(sendBuffer, i); i = j = 0; sendBuffer[i++] = LCD_ADDR; sendBuffer[i++] = REG_SEL_1; while( ( (c = text[j]) != '\0' ) && j < HAL_LCD_LINE_SIZE ){ sendBuffer[i++] = lcdConvertChar(c); j++; } for ( ;j < HAL_LCD_LINE_SIZE; j++){ sendBuffer[i++] = lcdConvertChar(' '); } smbSend(sendBuffer, i); }
This function writes a line of text on an LCD (communicates using I2C). A typical call to this function looks like this:
halLcdWriteLine(1, "Hello world");
Please help if you can.
Since most embedded processors are low on RAM, a compiler would normally place constant strings into the flash, i.e. CODE space.
Your function seems to expect that you always do a sprintf() or similar to format a string into a temporary buffer before passing the data for display.
It is always a big problem figuring out the best function signatures when working with processors with separate address spaces. The generic solutions tends to waste a lot of RAM or CPU time, while the possible optimizations are non-generic and tends to fail for some situations.