Development Tools
  how to create 4K byte array without xdata?

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   how to create 4K byte array without xdata?
yatink
New Member
posted August 11, 2010 11:16 PM     Click Here to See the Profile for yatink   Click Here to Email yatink     Edit/Delete Message
hii
I'm using C8051F005.

In my project I have and array of 4096 bytes.
As you all know external in chip ram is 800 bytes only so I can't use xdata in my application.

When I tried to declare it in program it gave me an error that data too large.

When I tried to declare it in code memory, it doesn't gave me any error. But when I tried to edit the elements of that array, they won't get edited.

At the end all elements in array remains 00H.

I want to know how to create array of this huge size?

Thanks in advance.

IP: Logged

Scotty
Member
posted August 12, 2010 12:54 AM     Click Here to See the Profile for Scotty     Edit/Delete Message
Hi yatink,

I'm using C8051F005.
...
As you all know external in chip ram is 800 bytes only so I can't use xdata in my application.

Hm, if my datasheet is correct the F005 has 2kB of on-chip XRAM.

In my project I have and array of 4096 bytes.
When I tried to declare it in program it gave me an error that data too large.

Of course, the compiler (usually) knows the size of the on-chip RAM. If the compiler doesn't know it directly it must be set via configuration.

When I tried to declare it in code memory, it doesn't gave me any error. But when I tried to edit the elements of that array, they won't get edited.
Code memory = flash memory. So arrays in code space must be initialized when declared, because the flash memory can not be modified directly by the compiler - however, the MCU can do it if you write the functions for reading/writing etc.
For example, the Keil C51 can be extended to access variables in code space like any other variable.
But, using the flash as a memory for variable data with high throughput has some disadvantages: you always must erase a flash page (512 bytes for F005) and therefore save the contents of the page to RAM, modify it, clear the page and rewrite it. This also takes some times.
So I suggest you use a external RAM. Usage is described in chapter 12 of datasheet.

Regards,

Scotty

IP: Logged

worknhard9062
Member
posted August 12, 2010 07:14 AM     Click Here to See the Profile for worknhard9062   Click Here to Email worknhard9062     Edit/Delete Message
As you all know external in chip ram is 800 bytes only so I can't use xdata in my application.

Hm, if my datasheet is correct the F005 has 2kB of on-chip XRAM.

Scotty,
Of course you've figured out by now that 800H or 0x800 == 2kB.

I just hope yatink understands this too!

------------------
Regards,
Steve C.

IP: Logged

erikm
Member
posted August 12, 2010 08:08 AM     Click Here to See the Profile for erikm   Click Here to Email erikm     Edit/Delete Message
So I suggest you use a external RAM. Usage is described in chapter 12 of datasheet.

I'd suggest, instead, to use a chip with enough internal XRAM (you can find up to 8k).

Erik

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | MCU User Forum

Have you seen our MCU Knowledge Base?


Ultimate Bulletin Board 5.47b