Menu

#10 Error in especifying a address

closed
nobody
None
5
2002-09-07
2002-07-29
Anonymous
No

Hi,

I´m working in a 8051 microcontroler and I have a device (a LCD)
placed in a specific address. I need to determine it´s address in
the program. I tryed to do that

sfr at 0x4000 LCD;

But it seens not to work. Running the S51 simulator, I realised that
every byte that I tryed to write to the LCD was writen to the
address 0x00 of the internal memory.

So I tryed this:

#define LCD (*(char*) 0x4000)

It works fine, but I get the message:

warning *** LITERAL value being cast to '_generic' pointer

How can I avoid this? There´s a better way to do that?

Thanks.

Discussion

  • Jesus Calvino-Fraga

    Logged In: YES
    user_id=603650

    You could try something like this:

    xdata char at 0x4000 LCD;

    void main (void)
    {
    int j;
    LCD=0x55;
    for(j=0; j<100; j++);
    LCD=0xaa;
    }

     
  • Jesus Calvino-Fraga

    • status: open --> closed
     
  • a_wombat

    a_wombat - 2005-08-16

    Logged In: YES
    user_id=1329887

    SFR's refer to a specific memory space in 8051 hardware. It
    strikes me that your 0x4000 address must be in the external RAM
    space of the 8051.

    try the xdata directive instead.
    ie:
    xdata at 0x4000 LCD;

     
  • a_wombat

    a_wombat - 2005-08-16

    Logged In: YES
    user_id=1329887

    SFR's refer to a specific memory space in 8051 hardware. It
    strikes me that your 0x4000 address must be in the external RAM
    space of the 8051.

    try the xdata directive instead.
    ie:
    xdata at 0x4000 LCD;

     

Log in to post a comment.