Best/Easiest code to learn first?

Discussion in 'Programmer's Corner' started by thakid87, Jul 28, 2010.

  1. thakid87

    thakid87 Thread Starter Active Member

    Joined:
    May 23, 2009
    Messages:
    122
    Location:
    Miami
    Just curious what the recommendations are.
  2. t06afre

    t06afre AAC Fanatic!

    Joined:
    May 11, 2009
    Messages:
    5,939
    On my travel suitcase I use 000 for the lock, very easy to learn:p Joking aside, can you tell more about which aplication segment/environment you plan to do your coding in.
  3. thakid87

    thakid87 Thread Starter Active Member

    Joined:
    May 23, 2009
    Messages:
    122
    Location:
    Miami
    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.

    THANKS!
  4. jpanhalt

    jpanhalt E-book Developer

    Joined:
    Jan 18, 2008
    Messages:
    3,778
    Location:
    Ohio, USA(GMT-5)
    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).

    John
  5. retched

    retched AAC Fanatic!

    Joined:
    Dec 5, 2009
    Messages:
    5,198
    Location:
    Baltimore, MD
    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.
    http://www.gooligum.com.au/tutorials.html

    Then check out BASIC. SwordfishBASIC and PICBASICPro are two to google. Also MIKROBasic. Here is a link to C, PASCAL, and BASIC compilers:
    http://www.mikroe.com/eng/categories/view/2/compilers/

    give em a look.
  6. big5824

    big5824 New Member

    Joined:
    Jul 15, 2010
    Messages:
    9
    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)
  7. nsaspook

    nsaspook Senior Member

    Joined:
    Aug 27, 2009
    Messages:
    1,113
    Location:
    Fairview, Oregon
    Just don't start with BASIC.:rolleyes: 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.
  8. Aule Mar

    Aule Mar New Member

    Joined:
    Jul 27, 2010
    Messages:
    4
    Location:
    USA, Maryland
    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.
    Aule
  9. nsaspook

    nsaspook Senior Member

    Joined:
    Aug 27, 2009
    Messages:
    1,113
    Location:
    Fairview, Oregon
    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.
  10. tom66

    tom66 Senior Member

    Joined:
    May 9, 2009
    Messages:
    2,613
    Location:
    Basingstoke, UK
    Python :).

    But it's not usually run on microcontrollers, so Assembly.

    Or C, because that works on pretty much everything.
  11. BMorse

    BMorse Well-Known Member

    Joined:
    Sep 26, 2009
    Messages:
    2,662
    Location:
    Vermontville, Michigan (GMT -5)
    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....

    B. Morse
  12. t06afre

    t06afre AAC Fanatic!

    Joined:
    May 11, 2009
    Messages:
    5,939
  13. davebee

    davebee Well-Known Member

    Joined:
    Oct 22, 2008
    Messages:
    527
    Location:
    San Francisco Bay area
    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.
  14. thakid87

    thakid87 Thread Starter Active Member

    Joined:
    May 23, 2009
    Messages:
    122
    Location:
    Miami
    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?

    Thanks.
  15. Potato Pudding

    Potato Pudding Active Member

    Joined:
    Jun 11, 2010
    Messages:
    681
    Location:
    Nova Scotia, Canada
    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.
  16. BMorse

    BMorse Well-Known Member

    Joined:
    Sep 26, 2009
    Messages:
    2,662
    Location:
    Vermontville, Michigan (GMT -5)
Similar Threads: Best/Easiest code
Forum Title Date
Programmer's Corner HELP! Passcode enabled blinking LEDs w/ arduino uno Aug 21, 2014
Programmer's Corner EEPROM test code problem. Jul 29, 2014
Programmer's Corner Hide C# Code Jul 1, 2014
Programmer's Corner large c programming project code examples for microcontrollers needed Jun 23, 2014
Programmer's Corner help over microcontroller code Jun 16, 2014

Share This Page