Hi,
I'm wondering if I am doing something wrong here. I am trying to store an array for a large 256 byte look-up table.
I have a pretty small 8051 MCU of 8 KB flash memory (IROM), 256 bytes internal RAM (IRAM) and 256 bytes on-chip external RAM (XRAM).
Prior to adding this look-up table, my current build from Keil reports:
"Program Size: data=54.1 xdata=0 code=1984"
I take that to mean I am using 54 bytes of IRAM, 0 bytes of XRAM, and 1984 bytes of IROM?
Here is the variable declaration I am using:
code unsigned char CRC8LookupTable[256];
When I define the CRC8LookupTable and populate values, I get the Segment Too Large error.
If you use "code" doesn't that store the values in ROM, which I should have plenty of space for?
Is there something else I need to add to that variable declaration?
Thanks -Tim
@Eric
This is entirely my point! The way CODE as a specifier/qualifier is treated is probably/maybe not consistent with the Bible of C. Who cares... not me.
So when I call the syntax for CODE bizarre, maybe you shouldn't be so dismissive cause that C Language has got a whole-lotta side-loops and exceptions all over the place. Lot of hands have touched it over the years.
Honestly, as someone without a stake in the Bible of C -- I have been using tentative declarations (I didn't even know what they were called!) and they've been working. But that CODE qualifier doesn't work like that. Fine... that's why I asked.
In my mind, why would you want to double type declarations between headers and source code? Now if you change a qualifier, you have to update it in two places. Plus the extra time double typing everything?
I really don't care if you consider that wise or stupid either. No need for a debate. It's like a debate over how many spaces are in indent -- who cares...?
ALSO -- there is a very clearly typed implementation for the next guy to figure out from the post. Karma on me, to pay something back to the forum.
End goal: the MCU is moving bits, and the code is modular and reusable and compiles on whatever target I need.
Guess what -- we don't write everything in my business in C either, it's just one of many computer languages we use! All of them have warts, wrinkles, and oddities.
OK, let's look at it
you have, in a module blah = ralph[i];
ralph is defined extern in an included header
the compiler, working on this module has no informationhus about 'ralph' except what is in that header thus it will (correctly) assume ralph is in DATA and create code accordingly. so if you want the compiler to use MOVC to access ralph, you must let the compiler working on that module know ralph is in code by including the qualifier on the definition in the header.
Just noticed this thread and was going to reply, but then saw what Erik says. He explains the requirement well. All that is meeded is a reaonable understanding of what a compiler does and what it is capable of.
Also, if you have this understanding for one environment, you will have a better chance of understanding for another.