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

How to use port P9 with 80C509

Hi all,

I want to link the port P9 to a LCD with a 80C509.

I have already linked a keyboard to the port P4 and I manage to declare a bit with this instruction:

sbit P4_0 = P4^0;

but when I try the same thing whit P9, the compiler says to me:

P9 : invalid base adress

I think it's because P9 is not bit adressable but I'm not sure.

So I try to read the value of P9 with this instruction:

unsigned char val = P9;

but the compiler says:

error C247: non-adress/-constant initializer

It seems that P9 is a constant, I can read its value but I can't change it.

Is someone who know how to do to change the value of P9?

Thanks.

ps: Sorry for my bad english, I'm a french student ;-).

Parents Reply Children
  • error C247: non-adress/-constant initializer

    "do you know why it's a constant?"

    It's not a constant; it's telling you that it needs a constant.

    I tried this, with just bog-standard 8051 stuff:
    #include <reg52.h>
    
    unsigned char global_val = P0;
    
    void main (void)
    {
    
       unsigned char local_val = P0;
    
    }
    I get Error C247 for global_val, but not for local_val.

    So it looks like nothing to do with P9, but something to do with initialised globals...

  • Thanks for the info Mr Neil.

    I found a solution. I have just written:

    void main (void)
    {
        P9 = 0x5F   // 0x5F is an example
    }
    

    and it works =)

    Thanks to all ;-).