View Full Version : stupid Array error: Error [1300] stack frame too l
Validius
26-01-2006, 20:04
It is choking on this declaration: `int table[255];`
I'm making it a lookup table.
devicenull
26-01-2006, 21:45
rom const int table[256];
Use that instead. Also, do you actually need int's? Do you values go above 255? Using unsigned char's would be more memory efficient
Validius
26-01-2006, 23:15
rom const int table[256];
Use that instead. Also, do you actually need int's? Do you values go above 255? Using unsigned char's would be more memory efficient
Yea, i was thinking about it and an unsigned char would work better. *runs to make a typedef*
Validius
26-01-2006, 23:17
rom const int table[256];
Use that instead. Also, do you actually need int's? Do you values go above 255? Using unsigned char's would be more memory efficient
what does the 'rom' part of it mean?
Eldarion
26-01-2006, 23:29
what does the 'rom' part of it mean?
I believe it places the array into the FLASH memory, not RAM.
Mark McLeod
27-01-2006, 10:21
The linker will only allow you to define a total of 256 bytes of global (or static) variables within any single project file. Variables are located in Data space where the values can be changed whenever you like.
If you want to create "char table[255]", it'll need to be defined in a file off by itself that doesn't have any other global or static declarations and referenced as an extern. "int table[255]" is too large to be defined anywhere but within the much larger Program space.
Using the keyword "rom" forces the array to be defined in (Read Only Memory) Program space rather than the Data memory, then you can be as large as you have program space for, but the values are fixed like your code statements and cannot be assigned or changed while your program is running. You have to pre-define the array values, e.g.,
rom const int table[255]={1,2,3,4,...255};
See pdf page 22 (document page 14) of the MPLAB C18 C Compiler User's Guide (http://ww1.microchip.com/downloads/en/DeviceDoc/C18_UG_51288e.pdf) for a description of rom vs ram.
Also discussed in this thread.
See the appropriate sections in C18 Users Guide (http://www.chiefdelphi.com/forums/showthread.php?t=30976&page=3&pp=15) (see pointer in reply #45):
2.3 Storage Classes
2.4 Storage Qualifiers
2.4.3 ram/rom Qualifiers
Because the PICmicro microcontrollers use separate program memory and data
memory address busses in their design, MPLAB C18 requires extensions to distinguish between data located in program memory and data located in data memory. The ANSI/ISO C standard allows for code and data to be in separate address spaces, but this is not sufficient to locate data in the code space as well. To this purpose, MPLAB C18 introduces the rom and ram qualifiers. The rom qualifier denotes that the object is located in program memory, whereas the ram qualifier denotes that the object is located in data memory.
Pointers can point to either data memory (ram pointers) or program memory (rom pointers). Pointers are assumed to be ram pointers unless declared as rom. The size of a pointer is dependent on the type of the pointer and is documented in Table 2-4. ...
Reading both sections of the user guide should provide a better understanding of storage declaration options available.
I'm assuming this is in MPLab. The same thing can be done in EasyC either using the "User Code" option. See EasyC discussion in EasyC Wish List (http://www.chiefdelphi.com/forums/showthread.php?t=42497) thread.
Regards,
DCBrown
Mark McLeod
27-01-2006, 10:53
See the appropriate sections in C18 Users Guide (http://www.chiefdelphi.com/forums/showthread.php?t=30976&page=2)(see pointer in reply #17):
Post #45 is the up-to-date 2006 version.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.