I was hoping to find on-line manuals that I could print and read on the john. So far no luck. But what I really need is how to declare variables in C.
For example, I have a sample code that has the statement:
unsigned char
and
unsigned long
What do these mean and do they limit the declaration to integers. What do i declare if I want a floating point?
Also, someone told me I cant do floating point with a Keil Compiler because of licensing issues (I got my copy from Silicon Labs and have just registered it). I will eventually need to do trig functions. What do i have to get (buy) to complete my project?
You don't need an on-line manual, you need actual literature on the basics of C programming. The C51 compiler manual is not a substitute for a book about C, nor is it intended to be one.
K&R (i.e. "The C programming language" by B. W. Kernighan and D. M. Ritchie) has already been suggested, and I strongly second that recommendation. After all, it's _the_ book about C written by the guys who invented C in the first place.
I will eventually need to do trig functions.
Using trigonometric functions does not require use of floating point arithmetics. In fact, part of the skillset of an embedded developer is coming up with solutions that fit the capabilities of the target hardware - and the '51 is very much unsuited for floating point math (even though the C51 compiler will not try to keep the programmer from shooting himself in the foot there).
There are other solutions, like using lookup tables and interpolation.
The embedded developer should also have the skill to assess whether the use of a professionally written, optimised and debugged floating point math library such as that supplied with the C51 compiler would either positively or negatively impact his project.
Reinventing an already nicely developed wheel if not absolutely necessary would, frankly, be plain stupid.
Yes, I do Fiber Optics. What do you do?
"Yes, I do Fiber Optics. What do you do?"
I'm just a menial who's done 8051 programming for the past umpteen-plus years.
I don't like to give too much away about myself here because I'd almost certainly be classed as a code monkey :(
I remember seeing one of your articles a while back. Nothing to do with my field, but it was easy to read and interesting.
I've been doing micro-controllers for 30+ years in assembly language. Sure, my experience is probably limited compared to you guys but give me a break. I admitted ignorance about C and ask for guidance and I create an argument?
That wasn't really an argument, more a lively discussion. The advice you got (get a copy of K&R and H&S) was spot on - it won't take long to get familiar with the basics of 'C' with K&R, H&S will answer any remaining questions you have.
I'd like to think I have the brains to figure out advantages vs disadvantages. Seems to me C was invented to get the job done fast and not efficient. My plans are, if needed, to optimize the code after the feasibility study.
I'd have said "C was invented to get the job done faster than assembly language and as efficiently as possible for a high level language".
Furthermore, from what I can tell, there must be better solutions than that offered by Keil, anyhow.
I'm not going to offer an opinion, but my impression from what I read is that Keil is probably the tool of choice if you wish to program the 8051 using 'C'.
I just bought the development package thru Silicon Labs and Keil doesn't want to support it and I am having difficulty ascertaining what I must spend to lift it's 4K limits.
From the sound of things you really bought a development board from Silicon Labs and it came with the trial version of the toolchain, or possibly a slightly enhanced trial version. You can't really expect to get a few thousand dollars worth of software for a hundred bucks.
Sharpening knives...
I'd like to think of it as Keil's loss. I'm going somewhere else if there is an option. I am sure there is an option. Like assembly language, lookup tables, and not Keil. Who needs to be part of the C community after this?
Anybody know of other development systems IO can consider to use with the Silicon Labs EVAL Kit? I've heard of http://www.avocetsystems.com.
Seems to me C was invented to get the job done fast and not efficient.
C was designed to be as close to the silicon as you can get without using assembly, actually. Hence, programs in C _can_ be very efficient.
Did you contact your local distributor of Keil products? He should be more than happy to provide you with a quote.
Well, how 'bout that. A fan.
Thanks for your comments. I'll have to put those in my scrapbook.
I'm at Renco Encoders now doing other strange stuff. Working on a real neat encoder solution. So simple I am surprised no one has thought of it. Well, maybe they have, I just cant uncover it.
Maybe I'll have one last hurrah before exiting ;)
In another forum there was a "which '51 compiler is bast" thread and several SDCC users stated "Keil is best" an IAR user stated "I think Keil is better". NONE stated that another product was better than Keil '51.
Erik
I'd like to think of it as Keil's loss. I'm going somewhere else if there is an option.
Hmmm. For someone with 30 years of experience in the field you seem to have an awfully light trigger. Running away like a startled deer, just because you witnessed a bit of banter among other users of the tool, and even "liking" that? Get real, mon.
I've been doing micro-controllers for 30+ years in assembly language. Sure, my experience is probably limited compared to you guys but give me a break.
On what basis should we have done that? Read your own OP again, slowly. What in there would make you guess that the author is anything other than a complete newbie on his first microcontroller project ever?
Calling that conclusion premature would be doing it an unjustified favour.
I am having difficulty ascertaining what I must spend to lift it's 4K limits. What crap.
crap? crap? I believe this is a feature of most commercial tool chains. what did you expect exactly? the source code along with the eval. binaries? and another thing: I also have expressed criticism here in the past regarding the tool chain and some of its extentions (FlashFS...) but you would not see me here calling it names like "crap". you give us a break - now often have you used the product to make sure a statement?
I meant: "such a statement?"
Sorry.
"crap" was referring the whole situation and not to the Keil product.
Perhaps my frustration should be directed towards Silicon Labs as they are the ones that sold me a development kit with a crippled Keil product.
Last embedded project I did, the manufacturer supplied the evaluation board and the development system (equivalent to Keil) all included for $79. Came with everything I needed to finish the project and we are in production. That is what I expected FROM SILICON LABS (emphasis - not shouting). I was wrong to blame Keil.
What I did not expect was the fight that insued herein because of my initial stupid questions, that, BTW, were promptly answered by the first poster.
I am sorry if I offended anybody. I am sure my comments could have been misinterpretted. I do favor assembly language over higher level languages and my comments about "waste" and "inefficiencies" are my opinion only and based on my beliefs. This was going to be my first C based project.
In my experience (only 25 years, I'm afraid), it is standard practice that the tools supplied with "dev kits" are just "evaluation" versions.
And free "evaluation" versions are always "crippled" in some way or another.
(in fact, I think the SiLabs kit gives you a slightly less limited version than the "standard" free evaluation?)
The exception is the single-source proprietary architectures like PIC and AVR - where the chip maker knows that the tools are useless with any chips other than their own. Therefore the tools can simply be considered as part of the marketing budget!
And free "evaluation" versions are always "crippled" in some way or another.<p>
"Ain't no such thing as a free lunch."
;)
And so we live in two different worlds. I have learned much. Thanks.
Good point. I said nothing about free. It cost me 79 buck-a-roos. ;)
Lou; It still applies, "read the small print". The Keil tools are fully functional but offset the 4K and restricted to 4K of linked code. There are free 8051 tools for 'C' and 'Pascal' for the "standard" 8051 but I'm sure that you chose the Silabs device for some non-standard features. Without questioning your programming abilities and your 8051 experience, I challange you to write some simple programs for the Silabs device using some of the non-standard featues. Write in both 'C' and assembly. Use some of the examples such as 'Blinky', etc. I'll bet the stripped Keil tools will make better ASSEMBLY code for these devices than you can write until you get up the learning curve on the SiLabs "deviates" as Erik calls them. As you have probably discovered by now, the Silabs IDE and tools have a fully functional, no restrictions assembler for their devices. One other thing, I recommend that you download the eval versions from this website. The tools that come on the eval CD are several versions old. The eval versions will have the same 4K restrictions. No,I do not work for Keil. Al Bradfrod Bradford
I can't even spell my own name but I have an excuse. I'm typing with a broken hand. Bradford
Fully functional? Part of my "what crap" expression was also because I read somewhere in the last two days that Keil was limited to 2K/4K and the floating point, including trig functions, dont work.
So actually, it appeared that I had "crap". Bunch of misinformation or misunderstanding, I guess.
So far my little C program has consumed 3K of the 4K limitation so I am VERY dissappointed with the efficiencies I see so far.
With regards to Blinky, come on, it's just initializing a port, setting a loop for a timer, and toggling a bit. But then again I dont know what you mean by "stripped Keil tools" but I cant imagine they can do better. Yeh, I know, there are probably some registers that need to be set (ie clk registers) but that cant be much. Yea, and you're right, there's a learning curve with assembly and, for me, C.
BTW, I chose SiLab because it was cheap enough, had 12 bit A/D (2 channel), a UART, some I/O, and the plus was -40 to +125 deg operation, and small footprint. Built-in clk, too. Dont know if all that is standard or special but if someone can recommend something else I'll listen.
Thanks for pointing out the unlimited assembler. No, I hadn't discovered it but since I am sure I will exceed the 4K limit by tomorrow, I'll need it. Not even doing floating point or trig yet.
Have you modified the compilers optimization settings yet? As default, the compiler produces completely un-optimized (i.e. large and slow) code that's easy to debug.
The Keil evaluation limitations are here: http://www.keil.com/demo/limits.asp
Both the 2K limit and the lack of floating-point are clearly stated.
Your "little" C program doesn't use printf, does it?
printf is a very powerful and, therefore, very large function - it can easily eat up most of the demo code limit!
You may well find that a small program that occupies 3k written in 'C' would occupy 300 bytes an assembly. That doesn't mean that a 600 byte assembly program would occupy 6k in 'C'. If you don't understand why, ask and I'll explain.
Unless you are pushing your 8051 derivative to the limit in terms of code size or speed than 'C' is almost certainly a good choice. I would suggest you persist with it but you will have to accept that you will have to buy the real version of the toolchain.
The code size limit you are approaching is designed, for obvious reasons, to prevent you from doing any serious work with it.
Bingo!
I am using printf for fun. Thanks for the tip. Now I can get rid of printf and replace it with atan and maybe be under the 4K limit.
This project is a very small project and should be done in less than 2K.
As I said, I'm a newbie to all this compiler stuff and Andy (and others) have given me good clues to work on.
Lou; Since cost and size of code was a concern, suggest that you look at some of the ARM Cortex-M3 devices by Luminary, ST and NXP. The eval tools have a 16K limit offset by 16K. Also, there are other tools that support C and C++. Cost of the chips are well within reach of the Silabs devices. SiLabs does offer the EC2 USB interface for target debug in your kit where you would need to purchase some type of JTAG iterface device for the selected ARM chip. You get a 16/32 bit chip at the 8 bit price with more memory and often higher clock speeds. Take a look at some of the data sheets linked on this website. Bradford
View all questions in Keil forum