| ARM Technical Support Knowledge Articles | |
Applies to: C51 C Compiler
Information in this article applies to:
I want to create a constant array larger than 64KB using the following construct:
#pragma ROM(D512K)
unsigned char const far array[] = {
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
:
}
Since the data is more than 64KB, I receive the error message:
*** ERROR C249: 'array': ALLOCATION EXCEEDS 64K
Is there a way to create a constant array larger than 64KB?
Yes. You may use an assembly program to define such an large array. Your example would translate into:
PUBLIC array ?HC?ARRAY SEGMENT HCONST RSEG ?HC?ARRAY array: DB 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 : END
The AX51 assembler has no limitations on the size of an array.
In C51 you may address this array as shown below:
#pragma ROM(D512K)
extern unsigned char const far array[];
unsigned char test (long l) {
unsigned char c;
c = array[l];
return c;
}
Note that the array index l is defined as unsigned long to allow 24-bit address arithmetic.
Article last edited on: 2005-10-10 11:08:32
Did you find this article helpful? Yes No
How can we improve this article?