3

I am using an ATMEGA16M1 microcontroller and the MPLAB IDE.

I have following function to write to the ports.

void Lcd8_Write_String(char *a)
{
    int i;
    for(i=0;a[i]!='\0';i++)
    Lcd8_Write_Char(a[i]);
}

void Lcd8_Write_Char(char a)
{
    pinChange(RS,1);             // => RS = 1
    Lcd8_Port(a);                //Data transfer
    pinChange(EN,1);             // => E = 1
    _delay_ms(1);
    pinChange(EN,0);             // => E = 04
    _delay_ms(1);
}

I call the function with Lcd8_Write_String("Hello World");.

I get:

error: passing argument 1 of 'Lcd8_Write_String' from pointer to non-enclosed address space.

How do I resolve this error?

Mike
  • 4,041
  • 6
  • 20
  • 37
Felix Kunz
  • 354
  • 2
  • 15

1 Answers1

7

If you write:

Lcd8_Write_String("Hello World");

The string "Hello World" will be in the Flash memory of your microcontroller and not in the RAM. So you had to switch your function to:

void Lcd8_Write_String(const char *a)
Mike
  • 4,041
  • 6
  • 20
  • 37