Best programming language for a microcontroller?

  1. So I've taken a course in java and gotten a solid grasp on it, I've learned using the arduino assembly language and messed around with it making some gadgets, and now I wan't to go further.

    I want to buy a pure microcontroller or processer without a board, and start programming simple stuff on it, later graduating to more complex stuff like video transmission and all the mind can dream off.

    What is the top tier final language engineers can use to do just about anything, like controlling a machine via radio and transmitting and recieving a radio using the same antennas. Even controlling a large LED screen, you get the point.

    So the question is, best language for microcontrollers for use in machines

    p.s. out of curiosity, what is windows written on?
  2. jcsd
  3. phinds

    phinds 8,346
    Gold Member

    assembly language will always do everything you want but it can be VERY tedious.

    C is generally the best language for stuff that is close to the hardware, but you'll need to be sure there is a cross-compiler for the microprocessor you decide on and that you have the wherewithal to move object code from the cross compiler output to the microprocessor.

    Windows is written for the Intel x86/Pentium platforms.
  4. Aren't there several types of C ? and if so what one to I choose, also I've tested arduino assembly language which in based on C I think and it all looks almost exactly like java, I think I'd adapt to C in no time.
  5. phinds

    phinds 8,346
    Gold Member

    No, there is only one C language. There is also C++ and C# but they are object oriented languages and not good if you want to stay close to the machine.

    You may be thinking of compilers. Of course there are numerous C compilers, but that's not what you need. You need a cross compiler.

    Do you fully understand the concept of what the BIOS is and what it does and what you have to do if you are doing raw programming on a microprocessor that doesn't have a BIOS ?
    1 person likes this.
  6. Nope. I have no Idea what a BIOS but Im guessing its something that that makes the processor be able to "talk" in C. Anyways since I need to get to the core I will choose C then, and yes C++ and C# is what I meant, I thought they were variatiants of C itself, apparently I was wrong. So what do I have to do to get my fresh out of the factory processor to work with C?
  7. When you say that you have used the "Arduino Assembly Language", do you mean this language?

    Code (Text):
      Reads an analog input on pin 0, prints the result to the serial monitor.
      Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
     This example code is in the public domain.

    // the setup routine runs once when you press reset:
    void setup() {
      // initialize serial communication at 9600 bits per second:

    // the loop routine runs over and over again forever:
    void loop() {
      // read the input on analog pin 0:
      int sensorValue = analogRead(A0);
      // print out the value you read:
      delay(1);        // delay in between reads for stability
    If this is what you mean, it is not Assembly, but C++ with a few custom libraries. Assembly depends on the architecture, and requires a knowledge of the available hardware functions, registers, and memory.

    C++ and C are both good languages for working close to the hardware without actually having to know what the hardware is. Of these, C is probably better.
  8. No processor speaks C natively. C must always be compiled to machine language, which is essentially Assembly with keywords swapped almost 1 to 1 with sequences of binary digits.

    Don't worry about that though. Almost everything has a C compiler; you just need to find it.
  9. I think you're a bit lost. The microcontroller/microprocessor has its own language (machine code). It is a certain configuration of 1's and 0's. That language has been abstracted into "assembly language" by the chip manufacturer. They provide you with an assembler to use to turn that abstraction into the machine code. C is another layer of abstraction on top of assembly abstraction. When you compile a C program it gets turned into assembly and then into the actual machine code (or some shortcuts therein).

    C is standardized. The specs must be purchased (but they're out there). Whether or not a particular C compiler will turn your C code into something correct (machine code-wise) for the target chip is probably the main thing to consider.
    Last edited: Dec 14, 2013
  10. phinds

    phinds 8,346
    Gold Member

    Jarfi, I mean you no disrespect but if you have no idea what a BIOS is then you are planning to go in WAY over your head. I suggest that you study basic computer architecture and then basic operating system architecture before you attempt your project. Right now, you don't even know what questions to ask.
  11. I know what you're saying but a microcontroller doesn't require a "BIOS". A microprocessor does. He seems to be leaning towards microcontrollers more. A microprocessor (more difficult to deal with from scratch) has no storage for a program. A microcontroller does and can be flashed or manufactured (internal "bios") with such..
  12. phinds

    phinds 8,346
    Gold Member

    A reasonable point as far as it goes, but I believe my comment is still valid. It seems to me that he doesn't understand the fundamental structure and interrelationship of hardware / operating systems / computer languages. I could be wrong about that. Jarfi, what do you say?
  13. Absolutely your comment is 100% valid, sorry if it came off as a negation. I agree he needs to understand architecturally what entails both IC types before proceeding (of which a bios is a key part of). I guess the reciprocal might have been if we said he needed to understand chip programmers before proceeding... which wouldn't necessarily apply much to the microprocessor (besides programming the bios lol).
  14. dlgoff

    dlgoff 3,045
    Science Advisor
    Gold Member
    2014 Award

    I agree. He could use an old PC with an older operating system and play with a this very simple language which can make calls to system interrupts thereby learning it's architecture.
  15. phinds

    phinds 8,346
    Gold Member

    Yeah, that's a good idea.
  16. First off, I'd like to say I am 19 years old studying physics with no educational backround in electronics, it is merely self taught apart from some java side courses. Most of my knowledge is assumptions based on observations I have learned over the past couple of months I've been discovering computer sciences and electronics.

    Now, I am simply trying to get a solid grasp on microcontrollers, if I'd have to program a microprocessor I'd probably just get somebody to help me with that.

    If I can program in C, turn it into the assembly code I need via compiler and then install that on my microcontroller, then that's all I really need. For now, I am not going to be learning hardcore computer science, I just started this.

    I want to program, run my C code on some chips and that's it, I don't ask for much more. This is what I am already doing with my arduino I am simply going here because the arduino is a prototyping board which doesn't offer you all the benefits of a custom cirquit board, mainly weight and size wise.
  17. If I were you I would start out with one of Microchip's PIC microcontrollers. It's very popular and there's a lot of beginner level books written for it. You can download a free IDE from their website. This IDE will allow you to write programs in assembly or C and it will compile and download them to your chip. There are a lot of PIC chips to choose from. I started with the PIC16F84. The only thing that may cost you, other than the chip itself, is the programmer. The programmer connects the chip to your computer and allows you to download your program to the chip. The one I used was the Microchip Picstart Plus. However, I noticed that the price for this has increased since I bought mine more than 10 years ago. There may be cheaper options available (but with limited capabilities).

    The things you need to do are: get a beginners book, get a programmer, download the IDE, get a breadboard and associated parts (resistors, capacitors, power supply, etc...), get the part you want to program, and download the data sheet for it from Microchip. Don't be intimidated by the data sheet. You will not need to understand everything on it to write your first program. Your book should explain what you will need to get from the data sheet.

    Good luck and have fun.

  18. Cost is not an issue, I am looking forward to start and thank you! That was crystal clear.
Know someone interested in this topic? Share a link to this question via email, Google+, Twitter, or Facebook

Have something to add?

Draft saved Draft deleted