Best programming language for a microcontroller?

In summary, C is generally considered the best language for working close to the hardware and is often used for microcontrollers and microprocessors. It is important to ensure there is a cross-compiler available for the specific microprocessor being used. Windows is written for the Intel x86/Pentium platforms, and there is only one C language, with C++ and C# being separate languages. To use C with a fresh microprocessor, a cross-compiler will be necessary. There are also other options such as using assembly language, but this can be very tedious.
  • #1
Jarfi
384
12
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 receiving 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?
 
Engineering news on Phys.org
  • #2
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.
 
  • #3
phinds said:
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.

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.
 
  • #4
Jarfi said:
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.

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 ?
 
  • Like
Likes 1 person
  • #5
Nope. I have no Idea what a BIOS but I am 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?
 
  • #6
When you say that you have used the "Arduino Assembly Language", do you mean this language?

Code:
/*
  AnalogReadSerial
  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:
  Serial.begin(9600);
}

// 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:
  Serial.println(sensorValue);
  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.
 
  • #7
Jarfi said:
Nope. I have no Idea what a BIOS but I am 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?

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.
 
  • #8
Jarfi said:
Nope. I have no Idea what a BIOS but I am 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?

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:
  • #9
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.
 
  • #10
phinds said:
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.

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..
 
  • #11
rp55 said:
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..

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?
 
  • #12
phinds said:
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?

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).
 
  • #13
phinds said:
I suggest that you study basic computer architecture and then basic operating system architecture before you attempt your project.
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 said:
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?

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 circuit board, mainly weight and size wise.
 
  • #16
Jarfi said:
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.

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.
 
  • #17
TurtleMeister said:
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.


Cost is not an issue, I am looking forward to start and thank you! That was crystal clear.
 
  • #18

1. What is a microcontroller?

A microcontroller is a small computer on a single integrated circuit that is designed to control specific functions of a larger system. It contains a processor, memory, and input/output peripherals on a single chip.

2. What factors should be considered when choosing the best programming language for a microcontroller?

The main factors to consider when choosing a programming language for a microcontroller are the application requirements, available resources, and the microcontroller's capabilities. Other factors to consider may include development time, ease of use, and compatibility with existing code.

3. What is the most commonly used programming language for microcontrollers?

C is the most commonly used programming language for microcontrollers. It is a low-level language that allows for direct access to hardware and is highly efficient in terms of both memory usage and execution speed.

4. Are there any other programming languages that are suitable for microcontrollers?

Yes, there are other programming languages that are suitable for microcontrollers, such as Assembly, BASIC, and Python. These languages may offer different levels of abstraction and may be more suitable for certain applications or skill levels.

5. How can I determine which programming language is best for my microcontroller project?

The best way to determine the best programming language for your microcontroller project is to research and compare the features, capabilities, and requirements of each language. You may also consider consulting with experienced programmers or testing out different languages to find the one that best suits your needs.

Similar threads

  • Electrical Engineering
Replies
10
Views
1K
  • Electrical Engineering
Replies
4
Views
5K
  • Electrical Engineering
Replies
1
Views
5K
Replies
8
Views
3K
  • Programming and Computer Science
Replies
6
Views
2K
  • Electrical Engineering
Replies
21
Views
23K
  • Electrical Engineering
Replies
30
Views
25K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • Programming and Computer Science
Replies
11
Views
2K
Back
Top