Difference between revisions of "Programming Languages"
(19 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
== Introduction == | == Introduction == | ||
− | Very high level languages are less suitable for microcontrollers, so the choices are less | + | Perhaps the title should be for '''Programming Languages Microcontrollers''', in any case that is what the content is now and probably should stay. |
+ | |||
+ | Very high level languages are less suitable for microcontrollers, so the choices are less than one would find on a PC. The main programming languages used in microcontrollers are Basic, C, and assembly. | ||
+ | Microcontrollers are generally harder to program than PCs because it isn't as easy to view debugging output, it takes more time to flash a new firmware, and the tools are generally less developed than PC tools. One suggestion is to learn basic programming on a PC first and then migrate to embedded systems after gaining some understanding. One hint on selecting a language is to always consider using the same language as the people you work ( play ) with do. This makes getting help much easier. Or pick a language with a strong support system on the internet. Of course the language cost and features matter too. | ||
== Basic == | == Basic == | ||
− | Some people consider | + | Some people consider Basic to be the easiest programming language to learn. The language is line oriented so compilers tend to produce more debugable error messages. |
+ | |||
+ | Basic encourages incrementally developing and testing software, an interactive technique that supports rapid application development. | ||
+ | |||
+ | |||
+ | Basic can either be interpreted as in the Basic Stamp from Parallax or compiled as in PicBasic. Generally speaking the interpreted basics run slower than the compiled basics. In some cases the basic firmware is part of the chip, this can boost the cost of the chip significantly. | ||
+ | Still this type of solution can get a beginner up and running quickly. | ||
+ | |||
+ | A Basic Stamp module from Parallax can get a beginner up and running quickly. | ||
+ | |||
+ | <s> | ||
+ | Traditionally basic has not required declaration of all variables and may not be strict about typing of variables, these can be a plus for beginners, by may be disliked by more experienced programmers. Not all Basics have these characteristics and some have optional settings. | ||
+ | </s> | ||
+ | === For Pics === | ||
* [http://www.crownhill.co.uk/section.php?section=1 Proton PICBASIC Development Section] | * [http://www.crownhill.co.uk/section.php?section=1 Proton PICBASIC Development Section] | ||
* [http://www.sourceboost.com/Products/BoostBasic/Overview.html What is BoostBasic] Compiler | * [http://www.sourceboost.com/Products/BoostBasic/Overview.html What is BoostBasic] Compiler | ||
− | * [http://gcbasic.sourceforge.net/ Great Cow Basic], open source compiler for Pics | + | * [http://gcbasic.sourceforge.net/ Great Cow Basic], open source compiler for Pics -- allows inline assembly, allowing more experienced programmers to do things not possible in pure Basic. |
== C == | == C == | ||
− | C is a middle level language that is considered to be high enough for productivity but close enough to the hardware to have some of the power of assembly. | + | C is a middle level language that is considered to be high enough for productivity but close enough to the hardware to have some of the power of assembly. C has free form formating rules so the look of C varies according to style and C compilers tend to produce harder to debug error messages. C is gaining in popularity over assembly with microcontrollers as embedded systems are becoming more and more complex. |
− | C has free form formating rules so the look of C varies according to style and C compilers tend to produce harder to debug error messages. C is gaining in popularity | + | <s>C is almost always compiled instead of interperated.</s> |
+ | Advanced C requires understanding of pointers which requires lower level understanding of the hardware than some people are interested in going. C compilers can be very expensive, however several free or demo versions of compilers are available. | ||
+ | |||
+ | === For Pics === | ||
+ | * [[Use C for PIC Programming!]] | ||
+ | * [http://sdcc.sf.net/ SDCC] supports 16fxxx and 18fxxx parts from Microchip. Open source. Integrates with [http://piklab.sf.net/ Piklab] and [http://eclipse-sdcc.sf.net/ Eclipse]. | ||
+ | * [http://www.htsoft.com/products/ Hi-Tech PICC] Pro, Standard and Freeware compilers for PIC10/12/16, PIC18, PIC24, dsPIC, and PIC32. OS X, Linux and Windows compilers available. | ||
+ | * [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010014&part=SW006011 Microchip C18] For 18fxxxx parts from Microchip. Integrates with MPLAB. Free student/Demo version is available that has some optimizations disabled. | ||
+ | * [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010065&part=SW006012 Microchip C30] For Microchip's DsPIC and PIC24 microcontrollers. GCC based with extensions. Free student/Demo version available. | ||
* [http://www.sourceboost.com/Products/BoostC/Overview.html BoostC Compiler Overview] Free for up to 2k of code, BoostC Full License US $69.95 The full license has unlimited RAM and ROM usage. Suitable for projects of all shapes and sizes. The definite choice of the serious programmer. Non-commercial use. | * [http://www.sourceboost.com/Products/BoostC/Overview.html BoostC Compiler Overview] Free for up to 2k of code, BoostC Full License US $69.95 The full license has unlimited RAM and ROM usage. Suitable for projects of all shapes and sizes. The definite choice of the serious programmer. Non-commercial use. | ||
+ | * [http://tutor.al-williams.com/picc1.htm C Programming with the Microchip PIC] tutorial | ||
+ | |||
+ | == Forth == | ||
+ | |||
+ | Forth is a low level language designed for extremely compact programs -- ideal for a microcontroller with little program memory. | ||
+ | |||
+ | Forth also encourages incrementally developing and testing software, an interactive technique that supports rapid application development. | ||
+ | |||
+ | === Forth for PICs === | ||
+ | |||
+ | (shamelessly cribbed from | ||
+ | the [http://massmind.org/techref/microchip/language/forths.htm Massmind list of Forths for PICs]) | ||
+ | |||
+ | * [http://www.rfc1149.net/devel/picforth PicForth], a Forth compiler for PIC 16F87x and 16F88 -- there is [http://tutor.al-williams.com/picforth1.htm a tutorial for PicForth] | ||
+ | * [http://www.ram-tech.co.uk/ IRTC], a Forth for the PIC18Fxxx microcontroller family. | ||
+ | * [http://mary.pepix.net/ mary], an Optimizing Forth Compiler for the PIC | ||
+ | * [http://flashforth.sourceforge.net/ FLASHFORTH] for the PIC18 and PIC24 microcontrollers and for the dsPIC30 and dsPIC33 DSPs. | ||
+ | * [https://devel.goto10.org/packets/wiki/purrr Purrr] is a Forth dialect for microcontrollers. Currently has a PIC18Fxxx microcontroller implementation. | ||
+ | * [http://pic18forth.sourceforge.net/ Pic18Forth] is a 16-bit implementation of the Forth programming language for Microchip PIC18Fxx2 microcontroller devices. | ||
+ | |||
+ | === Forth for other microcontrollers === | ||
+ | |||
+ | See | ||
+ | [http://forthfreak.net/index.cgi?StandAloneForth the list at ForthFreak], | ||
+ | [http://massmind.org/techref/language/forths.htm the list at Massmind]. | ||
+ | |||
+ | |||
+ | == C++ == | ||
+ | |||
+ | |||
+ | C++ is an extension of C. Many people consider C++ an object oriented language. | ||
+ | |||
+ | Some of the extension include: | ||
+ | |||
+ | * Associations between data( classes ) and functions ( member functions ) that operate on that data | ||
+ | * Modifications to existing classes through an extension method called inheritance without requiring modifications to the original code | ||
+ | * Operator and function overloading | ||
+ | |||
+ | C++ is not as common as C for microcontrollers mostly because many microcontrollers are not powerfull enough to run software large enough where the extra features become imporant. C++ is not supported by as many compilers as C for microcontrollers. | ||
+ | *[http://www.sourceboost.com/Products/BoostCpp/Overview.html BoostC++ Compiler Overview] | ||
+ | |||
+ | == Assembly == | ||
+ | |||
+ | Assembly is a near exact mapping to the actual instructions executed by processors. It is very processor specific. | ||
+ | <s>Some architecture such as the older PIC processors are optimized for assembly programming where some RISC based architectors are optimized for higher level languages.</s> | ||
+ | |||
+ | Some C compilers do not produce the best possible code so writing in assembly can theoretically produce faster code, but poorly written hand assembly can be worse. | ||
+ | Some people mix C and assembly in the same project and most compilers make it easy to integrate assembly in C programs. | ||
== Other == | == Other == | ||
+ | |||
+ | * See the compiler section of [[PIC Links]] | ||
We should expand this section, but for now will just mention some names, you can google them: | We should expand this section, but for now will just mention some names, you can google them: | ||
+ | |||
* JAL Just another Language | * JAL Just another Language | ||
− | * | + | * [http://pyastra.sf.net/ Python] |
− | |||
− | |||
− | |||
− | + | [[Category:Microcontroller]][[Category:PIC]] |
Latest revision as of 00:26, 8 May 2013
Contents
Introduction[edit]
Perhaps the title should be for Programming Languages Microcontrollers, in any case that is what the content is now and probably should stay.
Very high level languages are less suitable for microcontrollers, so the choices are less than one would find on a PC. The main programming languages used in microcontrollers are Basic, C, and assembly. Microcontrollers are generally harder to program than PCs because it isn't as easy to view debugging output, it takes more time to flash a new firmware, and the tools are generally less developed than PC tools. One suggestion is to learn basic programming on a PC first and then migrate to embedded systems after gaining some understanding. One hint on selecting a language is to always consider using the same language as the people you work ( play ) with do. This makes getting help much easier. Or pick a language with a strong support system on the internet. Of course the language cost and features matter too.
Basic[edit]
Some people consider Basic to be the easiest programming language to learn. The language is line oriented so compilers tend to produce more debugable error messages.
Basic encourages incrementally developing and testing software, an interactive technique that supports rapid application development.
Basic can either be interpreted as in the Basic Stamp from Parallax or compiled as in PicBasic. Generally speaking the interpreted basics run slower than the compiled basics. In some cases the basic firmware is part of the chip, this can boost the cost of the chip significantly.
Still this type of solution can get a beginner up and running quickly.
A Basic Stamp module from Parallax can get a beginner up and running quickly.
Traditionally basic has not required declaration of all variables and may not be strict about typing of variables, these can be a plus for beginners, by may be disliked by more experienced programmers. Not all Basics have these characteristics and some have optional settings.
For Pics[edit]
- Proton PICBASIC Development Section
- What is BoostBasic Compiler
- Great Cow Basic, open source compiler for Pics -- allows inline assembly, allowing more experienced programmers to do things not possible in pure Basic.
C[edit]
C is a middle level language that is considered to be high enough for productivity but close enough to the hardware to have some of the power of assembly. C has free form formating rules so the look of C varies according to style and C compilers tend to produce harder to debug error messages. C is gaining in popularity over assembly with microcontrollers as embedded systems are becoming more and more complex.
C is almost always compiled instead of interperated.
Advanced C requires understanding of pointers which requires lower level understanding of the hardware than some people are interested in going. C compilers can be very expensive, however several free or demo versions of compilers are available.
For Pics[edit]
- Use C for PIC Programming!
- SDCC supports 16fxxx and 18fxxx parts from Microchip. Open source. Integrates with Piklab and Eclipse.
- Hi-Tech PICC Pro, Standard and Freeware compilers for PIC10/12/16, PIC18, PIC24, dsPIC, and PIC32. OS X, Linux and Windows compilers available.
- Microchip C18 For 18fxxxx parts from Microchip. Integrates with MPLAB. Free student/Demo version is available that has some optimizations disabled.
- Microchip C30 For Microchip's DsPIC and PIC24 microcontrollers. GCC based with extensions. Free student/Demo version available.
- BoostC Compiler Overview Free for up to 2k of code, BoostC Full License US $69.95 The full license has unlimited RAM and ROM usage. Suitable for projects of all shapes and sizes. The definite choice of the serious programmer. Non-commercial use.
- C Programming with the Microchip PIC tutorial
Forth[edit]
Forth is a low level language designed for extremely compact programs -- ideal for a microcontroller with little program memory.
Forth also encourages incrementally developing and testing software, an interactive technique that supports rapid application development.
Forth for PICs[edit]
(shamelessly cribbed from the Massmind list of Forths for PICs)
- PicForth, a Forth compiler for PIC 16F87x and 16F88 -- there is a tutorial for PicForth
- IRTC, a Forth for the PIC18Fxxx microcontroller family.
- mary, an Optimizing Forth Compiler for the PIC
- FLASHFORTH for the PIC18 and PIC24 microcontrollers and for the dsPIC30 and dsPIC33 DSPs.
- Purrr is a Forth dialect for microcontrollers. Currently has a PIC18Fxxx microcontroller implementation.
- Pic18Forth is a 16-bit implementation of the Forth programming language for Microchip PIC18Fxx2 microcontroller devices.
Forth for other microcontrollers[edit]
See the list at ForthFreak, the list at Massmind.
C++[edit]
C++ is an extension of C. Many people consider C++ an object oriented language.
Some of the extension include:
- Associations between data( classes ) and functions ( member functions ) that operate on that data
- Modifications to existing classes through an extension method called inheritance without requiring modifications to the original code
- Operator and function overloading
C++ is not as common as C for microcontrollers mostly because many microcontrollers are not powerfull enough to run software large enough where the extra features become imporant. C++ is not supported by as many compilers as C for microcontrollers.
Assembly[edit]
Assembly is a near exact mapping to the actual instructions executed by processors. It is very processor specific.
Some architecture such as the older PIC processors are optimized for assembly programming where some RISC based architectors are optimized for higher level languages.
Some C compilers do not produce the best possible code so writing in assembly can theoretically produce faster code, but poorly written hand assembly can be worse. Some people mix C and assembly in the same project and most compilers make it easy to integrate assembly in C programs.
Other[edit]
- See the compiler section of PIC Links
We should expand this section, but for now will just mention some names, you can google them:
- JAL Just another Language
- Python