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
Bizarre, but it works and I can call it from other source files. what is bizarre about things working when they are done right?
I do not know if, for some reason, your original mess would be supposed to work, but a compiler that fails because of code in a header file is, in my opinion, bug free
@Erik -- If you were building a compiler, why would you treat the case where you put code and require that to be declared and defined in two places?
When are other variables used like that? I'm sure there is a reason from a compiler perspective, but from an end user perspective when you shift around fundamental behaviors like that, it seems a bizarre.
Have you ever read the definition of bizarre? It doesn't imply standard of "rightness" or "wrongness" -- it is just unusual, as in atypical usage of a variable in C...
When you say things are "right" with Keil's compiler -- it's pretty relative. I'm not getting metaphysical on a compiler. We aren't just a Keil C51 shop in my business.
PIC's compiler at least provides an error that you need to declare and initialize at the same time if you use const. In that sense, as being more clear does make it their compiler "better"? Maybe Keil could add a similar warning to their compiler, and make it easier to use. Doesn't seem like a crack-pot idea. Easier products for end-users, more end users who make more money using the tool... seems pretty straightforward.
Geez man - I don't get your snark. Do you work for Keil?
A compiler is a relative construct -- likewise conforming C standards. Whatever -- just a tool for a job. I don't have any religious zeal to software languages and standards. I try to write good code that is portable and re-usable. But I am all moving bits around for money. I'm surely not putting in a CRC routine, on a beautiful spring, just because.
I literally don't care how Keil wants to implement things. Seriously. Their product, their compiler -- whatever. They can do it anyway they want. I would wish maybe they illustrated this point a bit better in their documentation, and maybe called it out with a more direct warning in their compiler.
End of the day -- we are building a cheap device using an 8051 and we plan to move thousand of units a month using these 8051s and save a bundle of money versus a PIC based implementation on each unit. If I have to fiddle with some Keil C51 semantics, no biggie.
Forum post is here for the next user, to save them some time. Mission accomplished. I'm out. I won't respond to anymore.
Way to be a nice neighbor, man. Remind me NOT TO EVER ASK YOU FOR PAID CONSULTING. You never know who is on the other end of the forum. Maybe we need some really tight assembly for one of these low-end MCUs, we pay $130/hr for good assembly all day long...
CONCUR WITH MR ERIK