By now you may be aware there are two ways of programming PIC
Most of the promotion for the PIC centres around programming in a language called BASIC.
This is a high-level language where a single instruction allows you to perform a complete task. It is promoted as the answer to the programmers dream - making programming easier and more powerful than
But there is another way. It uses the 33 instructions directly understood by the
microcontroller. These instructions are called Assembly Code.
Let's look at the two and see how they compare. An absolute beginner might be swayed into believing BASIC is the best approach for his particular application, due to the amount of advertising
material presented in this direction.
But when you take take a totally impartial look at the pro's and con's of the two methods you may come up with a completely different answer.
The difference starts right at the beginning. If you want to take the assembly-code path you are on your own. Up to now there has not been any books or kits to guide you into programming PIC microcontrollers via assembly code (mnemonic) programming. The reason is the lack of profit. There is nothing to be gained by anyone promoting this path. You can do everything yourself and no middle-man is needed.
The only way to create a business out of programming is to invent another language and
charge for it.
That's exactly what has been done with BASIC. A clever programmer has produced a set of routines and placed them in a chip. These routines cannot be viewed and you can only stand back and use them "at arm's length". It's a bit like inventing a new language consisting of a single word to represent a sentence and suggesting it is better than learning the individual
Maybe it is. But the problem for the beginner is he has to learn one of the approaches and by learning the individual words he can construct his own sentences and know exactly how the language (microcontroller) works.
After seeing glossy advertising telling you "BASIC gets you into programming faster," let's suppose you
decide to choose it.
The underlying fact is: you are not told of the HIGH COST!
If you want a copy of the program you have written in BASIC you have to buy a further set of chips containing the BASIC routines - and this is very expensive.
BASIC is ok for a "one-off" hobbyist endeavour. But suppose you find programming a "buzz" and hit on an idea that can be turned into a commercial venture.
This is where the crunch comes.
A program written in BASIC will cost $20.00 to $40.00 per unit.
If you write a program in machine code, it will cost as little as $5.00. A PC board containing the chip, program and components can be produced for under $15.00. The difference between $15 and
$45 is enormous. BASIC leaves you no room for marketing your ideas.
Your only solution is to re-write the program, this time in ASSEMBLY
Logically, why not start with assembly code in the first place and if an idea comes along, you won't have to start afresh.
And there are more points.
If you are starting out, both paths will require about the same amount of learning and
If you have studied BASIC before, it will have a few familiar terms but very few young
electronics enthusiasts will have had previous experience with BASIC.
Another feature that we must expose with the products using the BASIC approach is the number of in-out lines. In
these designs, some of the in/out lines have been used by the product itself. In
one case, the 13 in/out lines of the PIC16F84 have been reduced to 8 lines.
If the project you are considering requires high speed operation, BASIC is definitely not the way to go. It slows down the execution of a program considerably.
The reason is the overhead (the BASIC INTERPRETER) adds extra instructions to the program.
The rate of slowdown varies with the program but can be in the order of 2 to 100 times or
The whole concept of a RISC-type microcontroller is the efficiency of its programming code. Why destroy this with inefficient programming?
If you are designing a real-time program such as a conversion routine; speed of operation is of major importance. That's one of the
MAJOR selling points of the PIC's range of microcontrollers, and was one of the reasons they were invented in the first place.
Lastly, the size a program.
An assembly-code program occupies considerably less memory than a BASIC program.
With a microcontroller running under BASIC, an extra chip is required to hold the BASIC routines. These "development modules"
(such as the "STAMP") may be using a PIC chip but the system never lets you get near the PIC instruction-set so you really can't be considered to be programming PIC chips at all.
In fact, almost any microcontroller could be the "host" to your program and it is just fortunate
(a FLUKE!) that a PIC was selected. FORTUNATELY, the STAMP etc, has brought PIC's to the forefront and promoted them very successfully.
It's a pity both sides of the coin have not been disclosed before. But, as you can see, advertisers have concentrated on a one-sided promotion.
Fortunately our course and the two books "PIC
Projects -1" and PIC
Projects - 2" will change all that.
Believe me, BASIC is a brilliant concept. We have copied the idea exactly and presented it in a form that gives you programming power while teaching the instruction-set for the PIC.
We have written lots of routines and given each a label in our "Library of Routines" chapter. Simple things like turning on an output, toggling an output line, detecting and debouncing a push-button, producing tones and sounds for alarms, delay routines and lots more.
You take the routines you require and add them to your program. All the routines are contained on a disk that comes with the course, so it's simply a matter of adding the routines as
In this way memory is not clogged up with unwanted instructions and everything runs at full speed with all the features of the micro, so there's no slow-down in operation.
Once you work with our method you will agree it's the cheapest and best way to go.
End of story.