I'm late learning C,I've always sucessfully avoided it in the past and still achieved what I needed in assembler for embedded, and VB for front ends.
I switched to Linux a couple of years ago. Recently, I attempted to load RIDE7 into a virtual machine (W2K on "virtualbox" under Ubuntu). It comes up with a bunch of scripting errors every time a file is loaded, or perhaps when info on one is updated, i.e., starting a project, and attempting to run a project. It also crashes.
As a consequence, I installed codesourcerys arm-none-linux-gnueabi package, gave it a path, and gave one of it's required prexisting components a path also.
I'm still lost though. For those of you who have grown up with C, it's sprawling nature is accepted, however, I'm used to assembler projects where the assembler handles a fixed processor brand, assembly file directives specify the processor model, and included files with processor memory map labels, int vector addresses, pheripheral addresses etc are all specified in one or other of the assembley files WITH a relative or absolute path, if not in the project path.
I see that some people use a "make" / "makefile" process to achieve some/all? of this, but I'm a novice ! it seems to be overkill to me, and I want to know what's happening, so I can diagnose any errors to their origin.
C, with it's reliance on include files, offers other people's work to shorten one's own development time and complexity, but somewhere, the common documentation seems to have failed in continuity re our end applications.
for example: I am currently trying to track down information on the following: 1) How to control output file types, i.e. hex, "elf" ? I don't even know what the "elf" acronym? is short for !, and intermediate assembly file step. 2) The difference between *.h and *.c source files ? 3) The best include files for common functions, i.e. string, math. Presumably, the better performing libraries will incorporate substantial as inline code, which locks it down to a much narrower processor range, hence I'm after a fairly specific file for each type of include function library. 4) A function to add a path reference for include files held within a common directory, is this available as a C directive ?
RIDE7 uses the codesourcery tools, so I'm not totally off the beaten path here.
If I can find good answers to these questions, then it's worth carrying on, and programming in C for the crossplatform advantages, despite the bloat versus pure assembly. Otherwise, I'd better get started with making/finding my own STM32103 assembler environment. I see someone else on an associated ST forum was hoping for a PDF data extractor for a similiar purpose... however, I think that the works already done in C files, and would be easier to extract/use directly ? for asm.
hi Graham, nice to see, you like asm , too. i get my primer toy in about 2 weeks, so i can only help a little this time:
:2: the ``.h'' files are by convention ``header files'' which contain definitions of variables and functions necessary for the functioning of a program :4: the path is given in the compiler settings or in a make file
Thanks Alf, Coincidentally,I have the contents of that link already printed and stapled together on my desk !
I also have been looking for the book referred to in the link: The C Programming Language -- ANSI C Brian W. C. Kernighan & Dennis M. Ritchie Prentice Hall, 1988 FYI, my primer had a defective cell, one of the NiMH? cells, there are notes not to overcharge them, but my one died before it got to even that state... fortunately, I had a couple of spare 900mAHr cells which I replaced them with.
My biggest concern with assembler re the STM32, is that many of the common library components are done in C on the STM website, so I will be coding a lot more from scratch. I believe C can be compiled such that the intermediate assembler output can be read from a file, presumably with variable names also, but then I wouldl have to untangle the C calling and parameter passing conventions to use them. That's an expected irritation for real number maths and example usage of pheripherals. I have an application for brushless motor control, and have the time, to do my own if needed. STM have a version that they will supposedly release with an NDA, but I'm not sure I even want to go there.
The cortex-m3 manual is extensive....
Still trying to figure out how to get a .hex file out of the compiler, looking like it's a two step process.
Graham, the old C standard book is the "Kernighan & Dennis M. Ritchie" , but dont waste your money on that. read the tut., and write some simple c-test-progs...this is more effective.
afaik using the c-headers and writing asm in a C-file could be the best way, to use asm here.
The more I get into C, the more I get concerned about where the various library files are stored, which reference which others, and all in all, it seems a very inefficient sort of a filing system to build algorithms with.
I prefer a language with compact, but intuitive format, and personal use of very descriptive variables.
In assembler, I convert many of my common pieces of code to macro form, and I have the choice of a call, or an inline macro. one bloats and speeds, the other is elegant, but sweats.
I see that the cortex has some mnemonics supposedly designed for C's switch statement... I've done similar in assembly anyway, so I'm looking forward to seeing if it makes life even simpler...
I have played with Python, and quite like it, especially the dictionary structures, which are very flexible, a bit like DIY registry structures. It's very compact, with tabs doing a much neater equivalent to C's curly bracket sets.
Here is a nice rule of thumb about the difference between .h and .c files;
Put preparation stuff that does not actually produce any object code* into header file(s). (that's #defines, extern variables refs, function prototypes [forward references]) *by object code I loosley mean anything that makes the code,constant,or variable space bigger)
another good rule of thumb is to start the .h file with #ifndef FNAME_H //where FNAME is the files forename, ideally unique in the project #define FNAME_H //blah blah //then end the files content with #endif
The nice thing about this is that if you accidentally include a .h file in your .c file when it is already included in another .h file, then whichever was included first get used, and the second one is skipped. In this way you do not get a slap on the wrist for making it clear what's included in your .c file.
I, like many people who play at programming, I cut my teeth on assembly language, from a few hundred lines of code to many thousands of lines. Each project I worked on might take quite a while to get through to complete it. I decided to go with ‘C’ a go when someone told me it was quicker to develop applications with. I could already program in ‘C’, used to use Borland ‘C’ and ‘C++’ under DOS on a PC. When windows came about I went the way of VB and VB.net. Why…..I will get to that in a bit.
I found the move to ‘C’ on the embedded platform a bit expensive at first but when a started to get into it, WOW it was great. When I look back at the assembly code I worked on I wonder how I found brains to write it??!!!
One thing about ‘C’ is it can grow around you. It is quick to learn but takes years to master. You can mould ‘C’ around your own style of programming.
You can work at high or low levels with ‘C’ by defining you own commands for it and building them into functions for yourself.
If you look at the work for the circle thing from ST, just brought one to look a day or so ago. You can see the code doesn’t look very ‘C’. Someone has written functions for the thing to support the hardware, graphics, i/o etc and has come away from standard ‘C’ functions. It also seems to use some kind of operating system to let you run your code inside it. For the same reason I don’t use ‘C’ on a PC is because you need all that function information to get your applications going.
The header files allow you keep code neat. You can write your own and use macros same the asm. You normally only include headers you need. Standard ‘C’ will add subtract multiply etc but you need the math library to do sin, cos etc. or your can write your own sin function if you want.