![]() |
|||||||||||||||||
![]() |
Custom Search
Readers
comments
|
||||||||||||||||
Why you need a pic compiler.What's the
simplest way to program
a PIC Micro? - "Use a PIC Compiler"...
"Download Your Essential Guide To Logic Level MOSFETs" "This is completely Free" CLICK HERE to DOWNLOAD NOW
Sponsored Links...
It's much easier working with a high level language (such as C or BASIC) because it uses words that are easily recognized by humans. This typically results in a program that is much easier to write and understand. In fact I would say that it takes about 1/10th the time to write a high level language program compared to writing the same program in assembler. This is because the complier hides the low level detail letting you get on with solving the problem. With a pic compiler you can visually describe the program flow using tabs and spaces making it easy to see how a program works. A good pic compiler also includes a help system for looking up elements of the language and a simulator which makes debugging the code easy. Compiler or Interpreter ?The other great advantage that a compiler has over interpreted language compilers is that you can get the maximum performance out of the chip. Compilers create executable hex files that run directly on the chip whereas interpreted language systems use an intermediate step and store an intermediate program either on the chip or in a separate storage device. Interpreting code from the memory takes time so you get less performance out of it. The one advantage that the interpreted system has is that since the memory device is separate it can be made as large as required - so you can create big programs. The fact that the interpreted language is slow is not advertised and you can tell the difference as a compiler will work with any chip but for an interpreted system you must buy a ready programmed chip - probably on a pcb. Compilers will work with any chip as long as you have a programmer. And this brings us to the next point - If you want to create lots of projects then for a compiler you have a one time non recurring cost - the compiler itself. But for an interpreted system you must keep buying the pcb and support chips - so your projects will cost a lot more to make. What is a pic compiler ?A pic compiler (or any compiler) is a program that translates one computer program into another. Source code written in a high level language is translated into machine code that the microcontroller understands. This simplifies the task since you do not have to write assembler - you are only concentrating on the high level language. Here is an example of a 'C' program and its assembler output i.e. the (machine code) output of the pic compiler : Example outputExample high level 'C' language source code for a pic compiler: void main() { Output generated by the compiler i.e. machine code (and assembler) : This following text is quite long please scroll down to past it to see comments about it and continue. ; ADDRESS OPCODE ASM it is using a compiled language over raw assembler. The second column is the actual machine code that the microcontroller reads (opcode) while the third and fourth are the assembler translation (a bit more readable than the opcode). As you can see the source code is much more compact than the assembler output and is far more readable. You can also see that it is doing something with PORTB and there is a delay included whereas with the machine code you can't really tell what is going on and there are a lot more lines of code to work through. Of course comments are (hopefully) included for hand written assembler but there are still the same number of statements to understand. What is the advantage of a pic compiler ?The compiler's language lets you...
A good pic compiler will also let you...
Types of pic compilerThere are two main languages used for pic microcontroller programming BASIC and C. These are by far the most popular languages and there are many compilers with varying cost/performance ratios. Other less popular pic compilers are PASCAL, FORTH and JAL. High level language compilers available for the PIC Micro:
Key features:ANSI standardized
Having an ANSI standard associated with a language means that any pic compiler can be used to compile the source code - and the compiler will accept that source code regardless of the target micro family. Note you may have to make some adjustments e.g. register names, hardware operation etc. It is a problem for BASIC as there is no standard - so if you write BASIC source code using one compiler it most likely will not work if you use a different compiler. Ease of use
Main benefit:
Main Disadvantage:
Availability for pic micro:
What to look for in a compiler.When starting out you should use a pic compiler that has a text editor and simulator built in known as an IDE (Integrated Development Environment). A good help system will give examples of the language which saves getting a text book out (Some help files also have examples of typical hardware solutions). Obviously cost is a consideration - the best are going to cost more. However you can use some that are very low cost and perform well. Jump from pic compiler page to Best-Microcontroller-Projects Home Page |
|||||||||||||||||
|
|
|||||||||||||||||
|
|||||||||||||||||