This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Warning: c259: pointer: different mspace

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.

Parents
  • Thanks Andy, I have considerably less warnings now. It seems in the declaration (in a header file), the function is meant to receive an XDATA type pointer but this wasn't reflected when the function was defined.

    i.e
    In the header (.h) file:

    void halLcdWriteLine(uint8 line, const char XDATA *text);
    


    In the source (.c) file:

    void halLcdWriteLine(uint8 line, const char* text){....}
    

    In spite of this, not all the warnings have gone away. Now i find the same warning wherever this function is called. An example of this function being called.

    halLcdWriteLine(1, "Hello world");
    


    The string "Hello world" is passed directly to the function.

Reply
  • Thanks Andy, I have considerably less warnings now. It seems in the declaration (in a header file), the function is meant to receive an XDATA type pointer but this wasn't reflected when the function was defined.

    i.e
    In the header (.h) file:

    void halLcdWriteLine(uint8 line, const char XDATA *text);
    


    In the source (.c) file:

    void halLcdWriteLine(uint8 line, const char* text){....}
    

    In spite of this, not all the warnings have gone away. Now i find the same warning wherever this function is called. An example of this function being called.

    halLcdWriteLine(1, "Hello world");
    


    The string "Hello world" is passed directly to the function.

Children
  • 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.

  • What did you actually change?

  • I added the memory space specifier in the source file (it wasn't there before) and that is how i got less warnings. The declaration (in the header file) had a memory space identifier but the function definition did not.

    To eliminate the warnings, I decided to use generic pointers throughout the program and it worked. I'll try tailoring the system for efficiency (use memory specific pointers) later once I know that at least everything works. Thanks guys, couldn't have done it without you.