Discussion in 'Programmer's Corner' started by thakid87, Jul 28, 2010.
Just curious what the recommendations are.
On my travel suitcase I use 000 for the lock, very easy to learn Joking aside, can you tell more about which aplication segment/environment you plan to do your coding in.
Haha, nice one. I'm looking for "simple" programs that I can then learn to load into microcontrollers in the future.
I quote simple because I really don't know how easy/difficult it would be to learn.
Code for what?
If you are starting with PIC's, I started with and still use Assembly. My prior coding experience was a Ti99/4 and some MS Basic 20 years previously. My reasons were simply: 1) MPLab completely formats the code for you, so all I needed to do was concentrate on the instructions -- I didn't have to worry about the formatting of something like C; 2) A lot of the code for what I wanted to do was available in Assembly, as were many tutorials; and 3) I liked understanding what was going on in the MCU. I also felt that since I was completely new to microcontrollers, why try to learn both a language like C and microcontrollers at the the same time. Assembly just seemed intuitive to me, once I had read the limited instruction set (e.g., for the 16F628A).
Look over some tutorials and see which programming language seems to make the most sense to you.
A big problem with many languages is you often have to "forget" what you learned in one language about coding when learning another.
So all things aside, if you learn assembler, you will be able to control every aspect of every chip in short order. PICs often have only 33 to 35 commands. That isn't many.
33 commands control every aspect of the uC. That is a list you can have printed out and sitting beside you while you code..on ONE PAGE..
When it comes to C, or even BASIC, there are dozens or a hundred or more commands and often cryptic ways of using each command. This can be VERY daunting to some.. Or it can make perfect sense to you.
Here is a site with tutorials. Each tutorial has ASM(assembler) and C code. You can see the difference in the languages and what is required to do what. See which language seems to make sense to you and go from there.
Then check out BASIC. SwordfishBASIC and PICBASICPro are two to google. Also MIKROBasic. Here is a link to C, PASCAL, and BASIC compilers:
give em a look.
Id say start with C. Its more or less pushed java out of the market now, and assembler is becoming less and less appropiate as devices become more complex, so basically everything seems to be moving towards C (or a varient of)
Just don't start with BASIC. If you plan to develop complex device software "C" in the long run is the better language because it keeps the code at a higher level logic and data flow but still allows you to easily toggle things at the bit level efficiently.
Something being easy is overrated.
I've programed in Basic, C, C+, Fortran, Lisp etc.
But when working with microcontrollers and logic circuts, there nothing like assembly, you actualy know exactly where the Bits are going, and If/when you upgrade to C for doing something complicated, you still get an assembly listing, and will know how to read that to debug your complicated code.
Very true, but you know how many times I've has to look at the ASM code to find a C coding error? Zero, and it's not because I haven't made some bonehead mistakes but because the compiler does so many optimizations it's almost a waste of time looking at it unless your tracing a compiler bug with a test case program to find it.
Knowing where all the bits are is NOT overrated but sometimes you have to be free from the chip level mentality while building a product.
But it's not usually run on microcontrollers, so Assembly.
Or C, because that works on pretty much everything.
I agree with jpanhalt, start with assembly, there is more code samples available on the net and tutorials for pic micros and assembly... since most C compilers cost money (They have some that are free but either limited in code size or optimizations when compiling) but MPLAB's MPASM assembly compiler is FREE..... and the syntax in C tends to vary quite a bit from compiler to compiler, so it may get a bit more confusing trying to look at someone elses sample C code form one compiler, while trying to write the same code in another compiler...
So if you are just starting out, assembler will be the basic stepping stone you need to get on first (Cheap, easy to learn instruction set, plenty of sample code and tutorials) you can almost guarantee if you were looking for sample code in assembly from the net that it was written and compiled with Microchip's MPASM (if it is a pic micro anyway), once you understand assembly you will be able to move onto other compilers like C....
You can also purchase a kit like this one http://parts.digikey.com/1/parts/1642636-kit-starter-pickit-3-dv164131.html It contain all you need to start developing. And 12 lessons in assembler is included. In the beginning you will most certainly struggle a lot. Perhaps feel like quitting. But we will be here to help you
It's not just the language; microcontrollers are very different in things like how much memory they have, how large a program they can hold, how to access internal ADCs and counter/timers, how difficult it is to load a program into them, how many IO pins are available for your project, even how much it costs - whether you need to buy a special programming device and cable, or buy a compiler/programmer to load the code in.
Some are more oriented towards hand-wired boards and some are more like blocks where you plug a project together without ever actually connecting a wire.
Plus, different microcontrollers support different languages - some offer C compilers, BASIC assemblers or Pascal-like higher level languages, but not every language runs, or runs well on all microcontrollers.
So if you want to get started using microcontrollers, I'd suggest that you read a little bit on the most popular half-dozen or so types. (The internet has plenty of information on them) and choose one not just on the available language but also on which one seems to fit your project and work style.
Thanks to you all for such helpful posts. I am going to take C programming courses later on in my college career. For the time being, I am interested in learning assembler. I've tried searching for a good source on google, but either I can't find one or I can't tell when I see a good one.
You guys have any sources for learning assembler code online?
I have been looking at this page, but I am not certain if it is the best resource out there.
I am looking at what languages I want to learn too. I am looking towards things like VHDL, and Verilog.
How about this one >> http://www.piclist.com/images/www/hobby_elec/e_pic6.htm << various pic projects
and this one >> http://www.winpicprog.co.uk/pic_tutorial.htm << good tutorials