Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Question about the PIC chip lineup

Status
Not open for further replies.
PIC Programming (compilers?)

Hi, I was wondering if anyone could tell me the advantages/disadvantages of using a C or Basic compilers (such as picbasic and C18/c30) as apposed to learning and using strickly assembly language.

As far as I know assembly is completely free and the compilers cost upwards of hundreds of dollars.

Also the microchip website says the c18 student edition will still compile after 60 days but may occupy more memory space. Does anyone know the specifics behind that? Such as how much more memory space. Will the expired student edition still be capable to program all the features of an individual PIC microcontroller? Or will some functions be unreachable?

Sorry if these questions have been asked and answered before and thanks in advance for you input.

RKB
 
Assembly

Assembly is the most efficient you can get. It makes the fastest software.

The problem with assembler is that you are working one level up from 1s and 0s. You are in control of absolutely every single aspect of operation. This allows you do do exactly what is needed and this allows for the fastest code possible (a higher level language such as C or BASIC does unnecessary roundabout operations when it compiles so the speed is slower). However since you have control over everything...that's the problem. You have control over EVERYTHING. So you must keep track of everything and deal with every little thing. If you make an error, you will never find it because even the simplest "English-level" operations take many many low level operations. It is so severe to the point where you can't even recognize that a chunk of code (that's right a chunk of code) just adds two numbers together. Have you ever seen an assembler example of adding two numbers together? Search for one. You will be suprised at how many low level operations are required to add two numbers together...you probably won't even recognize what the code is doing.

Imagine designing a jet engine. That is like C++ or BASIC. It's already pretty hard right? Now imagine designing a jet engine from the molecular level where you have to keep track of where every molecule is and what it does. That's assembler.

As for the Microchip C18. If you download it and install it into MPLAB2 and search around the options/settings, there are compiler optimizations that you can select which make your code smaller or faster, etc. Some are for speed, others for code size. One of them decides whether or not the compiler actually makes an inline function inline, if not it just ignores the "inline" keyword.

Install it and take a look at the options. I decided that the other options were not worth my $800 for me. Mainly because a lot of them alter the way your code is organized while you compile (and I kind of like my code to run exactly the way I wrote and organized it). Without the optimizations, it won't make your code take up "more" space than normal. It will actually only take up just as much space as how you coded it. It COULD be smaller and that's what the optimizations do. The only option that peeved me was the inline function, because it was the only one that would cause my code to not run the way I typed it. So I just don't use the inline keyword. Your code will work the way you typed it and EXACTLY the way you typed it without and increase of speed when these optimzation options are disabled, with the exception that any inline functions will not be inline (they will be compiled as regular functions).

You do know what inline means right? The code of a regular functions only appear once in memory and whenever the function is called, the program runs that one body of code. Space is saved, but speed is sacrificed because the program has to go to that section of code every time the function is called. Adding the inline keyword makes the entire function's code appear at every single location where it is called. This saves speed because the function's code is always right there when the function is called, but it takes space because the identical coding of the function appears many times in the code. THat is all.
 
Last edited:
Thanks for the info Dknguyen, that information helps me a lot. I'm actually working on my BA in computer science so coding comes pretty naturally to me.

I'm rather in the same boat, I like my code the way it is too. To me coding is rather like writing a story. I can write it, make it work, but its just a rough draft. I edit many many times in order to simplify, in favor of better, faster functions ect.. I actually got into the electronic side of computers recently because of my dad. I wrote a program for him to work with his outdated DMM/datalogger (his old software originally written for win3.1!).

These forums are great, I have a feeling I'll be visiting often over this summer. Once again, thanks for your input Dknguyen.

RKB
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top