![]() |
||||||||||||||||||||||||
![]()
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() I use
and
recommend Firefox for the best internet browsing experience. Click below for your free copy today: CLICK
THE IMAGE:
Note:
I find it faster
and easier to use and it has great plugins. It even imports all your current browser settings! There's
no risk as your existing browser is not affected in any way - you can just choose which
one to use.
|
|
It's called GCBASIC and its for PIC microcontrollers using syntax similar to QBASIC/FreeBASIC.
Useful For You. Readers
comments
|
||||||||||||||||||||||
PIC BASICBeginners All Purpose Symbolic Instruction Code for PICS.BASIC is a good choice
when you are starting out...
BASIC is the simplest language and must not be dismissed because it is old. It's true it has some limitations (modern compilers do not have many limitations) but it is excellent when you are starting out... There's even a free one called GCBASIC. BASIC was the first language that I ever used and PIC BASIC is BASIC optimized for the PIC Micro. OK I'll date myself a bit here - MZ80K, Spectrum, Amstrad - the heady days of the Z80 based computer which all used BASIC. BASIC has improved over the years getting rid of line number based listing and using the procedure based method common to other languages. This fact alone makes PIC BASIC much easier to use e.g. instead of GOSUB 9810 (a line number) you can use GOSUB abc where abc is the name of a subroutine. But it has not changed that much and this explains its popularity - you can use the BASIC that you learnt years ago and program advanced PIC Micros. There are several PIC BASIC systems and these are either interpreter or compiler based. Jump to Interpreted or Compiled ? Jump to Interpreter, Pros, Cons. Jump to Compiler, Pros, Cons. If you are new to programming, PIC BASIC is also a very easy introduction to microcontroller programming as the language is not difficult to master. I
expect that later on you can move onto other languages as the only
disadvantage of PIC BASIC is that sometimes, for advanced programming,
it
limits what you can do.
In the past at work I have been asked to program in an ancient version of BASIC and it is extremely frustrating as you tend to rely on the features of the program i.e. you start programming because it claims to be able to do something. Once you get there you find you would like to add a tiny extra operation and you can not! There is simply not enough functionality in the functions provided and you can not add any more. C tends to let you do more as most of the functions are themselves written in C - this basically means that if a function is not available you just write it yourself. This is why the 'C' language is so popular you can do virtually anything you need to do in 'C'. Also you can structure the program more easily and this lets you more easily understand how the program works but PIC BASIC is still powerful and modern versions let you do much more - even adding your own assembler code. Note: Even with advanced programming limitations you can still do an enormous amount using PIC BASIC. Sidebar : GOTO Note: Use of GOTO is not considered good programming practice. The reason is that when you use it you have no way of getting back to where you started. The program's flow is completely disrupted and you are dependent on the routine that you are in to get you to the next program operation. (This is ok for a small test program but hopeless for anything large). You need to use GOSUB - better to just not use GOTO at all. A procedure that you have called using GOSUB will let you go back to the caller at any time using RETURN. This method is equivalent to procedure/function calls in all other languages (Yes C does have a goto statement but everyone avoids it at all cost). Using subroutines structures your code for easy reading and maintenance as you can use your main procedure at the top level - if you think of your program as a root system that branches down. Each branch represents a single subroutine and side branches off of these represent more subroutines. PIC BASIC : Interpreted or compiled - What is the difference ?There are two flavors of BASIC for PIC Micros:
Interpreted PIC BASICFor each instruction e.g. FOR, RETURN, GOSUB etc. a unique code is assigned to the token - this is simply a number. These are read from memory and interpreted sequentially. Note: Special methods are used to distinguish between 'Tokens' and a number e.g. a WORD. The key points here are :
Interpreted PIC BASIC : Controlling programThe interpreter is a controlling program that interprets the tokens and it has to be present in the microcontroller and it will be quite large - so you loose some of the internal program memory of the PIC.The amount of memory you loose depends on the commands supported and in some cases this does not matter as the tokens are loaded into a separate external memory (serial eeprom) while in others only internal memory is used . Interpreted PIC BASIC : On-the-flyThe process of interpreting a token takes the following steps:
Interpreted PIC BASIC : Ease of useThe saving grace for a BASIC interpreter is that it is easy to use and the one feature that gives it an edge over a compiler based language is:You only need a serial cable to
program it (e.g. picaxe).
They work using the PIC feature of self programming where the PIC can write to its own internal (Flash) program memory (not the EEPROM). Note: This is effectively a bootloader with added 'BASIC' functions. It bootloads the program into internal memory or I2C serial EEPROM and executes it. Interpreted PIC BASIC : Disadvantage ?Its slow and in the long run it costs you more.Also some features may not be available e.g. interrupts - you need to carefully check the documentation before buying it. Note: picaxe may be an exception as it is priced a little bit more than the cost of the chip (ok it still costs more than the chip). Interpreted PIC BASIC : Advantage ?A PIC BASIC interpreter is the easiest way to start programming with microcontrollers.Compiled PIC BASICA
PIC BASIC compiler, although the front end tools look virtually
identical
to a PIC BASIC interpreter, outputs either assembler code or a hex file
that you
can directly load into your PIC Micro. There are no tokens
and no intermediate steps so you can drive the Microcontroller at the
fastest possible speed fetching instructions from internal memory and
executing them immediately.
The compiler directly outputs
executable code.
The compiler is the favored method of program generation in industry as it gives you complete control over the microcontroller but the C language usually used. PIC BASIC Compiler : Disadvantage ?Separate programmer and programming software running on the PC.This adds more complexity to programming the chip. i.e. you have either a serial or parallel cable (or USB) to the programmer circuit and then an ICSP connector to your target board and you use PC programming software to stuff the data into the microcontroller. Note: There is a way around this - by using a bootloader - this consumes a small amount of internal memory (but is not as big as the interpreter). But you still need a programmer to get the bootloader into the Micro in the first place - this is what you buy when you buy a BS2 or picaxe i.e. a bootloader and interpreter combined. PIC BASIC Compiler : Advantage ?A PIC BASIC compiler gives the maximum speed and best use of internal program memory and resources.Also, once you have bought the compiler you do not need to buy any other module (usually a costly component) you just buy the raw microcontroller chip. Note: Costs can mount up if you use interpreted BASIC modules. e.g. if an interpreter module costs $50 each and you do ten projects it will cost $500 (just for the module). If you buy a compiler $200 say and do ten projects (with a $10 microcontroller) then you spend a total of $300. So if you intend to do a lot of project work it's worth investing in a good compiler (but check picaxe price). There's a free open source PIC BASIC compiler here. Jump from PIC BASIC page to Best-Microcontroller-Projects Home Page. |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||