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

Using an Array

Hi I have the following array declared at the start of my program as global:

int number[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98};

0 1 2 3 4 5 6 7 8 9

It is for a 7 segment display to display the numbers that I need, the array is from 0-9 in that order.

My code to call the array is:

P2 = number[4];

so in this case it should get the 4th number being 0x99

This works fine if i replace the 4 with 0,1 or 2 but anything greater than 2 all it does is return the data for 8 (80)

If anyone can work out why this is doing this please let me know

Thanks

Parents
  • May be a problem with the RAM in your target hardware.

    You should define it in ROM using the code memory type.

    Change definition to:

    unsigned char code number[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98};
    

    Also read the C51 User's Guide to get a better understanding for the memory types.

    Reinhard

Reply
  • May be a problem with the RAM in your target hardware.

    You should define it in ROM using the code memory type.

    Change definition to:

    unsigned char code number[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98};
    

    Also read the C51 User's Guide to get a better understanding for the memory types.

    Reinhard

Children