If you are interested in programming then you are definitely familiar with some programming language and probably written few programs or compiled few codes. If you are not, then I strongly insist that you check it out first i-e read the basics of programming. Writing codes for the 8051 microcontroller is not much different. You choose some programming language for yourself and then you start writing codes in the correct environment. That's all it takes.
UPDATE: You can also click this link for an updated version of this post.
UPDATE: You can also click this link for an updated version of this post.
There are two languages that you can use to program the 8051.
ASSEMBLY LANGUAGE
It is basically a low level programming language for computers and is machine dependant which in simple words means that the code you write for one machine will not be compatible with some other machine. It is composed of words-like instructions called MNEMONICS. Actually I am not going to talk about assembly language in here because that's for you to learn and practise. So I have made my call. For getting familiar with the assembly language (if you're not already), you must check here for reference (I guess it's the third one you need).
The basics of Assembly language and the 8051's instruction set will be sufficient for programming. I mean that's all you will ever need. Nothing more nothing less.
C LANGUAGE
It is a high level programming language and is most commonly used almost everywhere. Most probably you're already familiar with it. Also if you are thinking that you know only C++ then don't worry because if you ask me, I had practised only C++ while I was learning about programming myself. Recently when I realized I had to use C language for the 8051, I thought it to be different than C++ but the good news is that II was wrong. When programming for 8051 in C, you will hardly notice that you are actually using C rather than C++. The minor difference I am talking about... you will get used to it anyway. My point is that you must first read about C language. Again, you need to check out the third reference here.
However, I will also explain C language for the 8051 in further detail when the time comes.
Which one to use?
It is indeed an important decision to make. Technically both languages are supposed to work just fine so selecting one won't make any difference. However, there is a catch.
Assembly language is very specific and a bit complicated. Being a low level language, it is not easily understandable at first sight but being very specific, it gives you total control over what you do. You can even determine the total machine cycles of the whole code you have written. You can call each register by name and store / manipulate values in it or you can generate exact time delays by using simple statements.
C language is not so specific and gives you freedom to program free hand and forget about the names specific to some device. You can start writing code in your natural way and the compiler will take care of the internal operations for you. This makes things a lot more easier as compared to Assembly Language. However, we can never know about the machine cycles executed by a single C statement as it is entirely dependent on the compiler you use.
My opinion? As a beginner with 8051, you must play only with Assembly Language so as to understand the flow of a code in the hardware sense. In fact, this practise will get you familiar with many aspects of the 8051 microcontroller and how to manipulate it efficiently. But once you get the hold of it you will realize that it is time consuming and that's where you jump to C language.
a sample Assembly Program |
C LANGUAGE
It is a high level programming language and is most commonly used almost everywhere. Most probably you're already familiar with it. Also if you are thinking that you know only C++ then don't worry because if you ask me, I had practised only C++ while I was learning about programming myself. Recently when I realized I had to use C language for the 8051, I thought it to be different than C++ but the good news is that II was wrong. When programming for 8051 in C, you will hardly notice that you are actually using C rather than C++. The minor difference I am talking about... you will get used to it anyway. My point is that you must first read about C language. Again, you need to check out the third reference here.
However, I will also explain C language for the 8051 in further detail when the time comes.
a sample C program |
Which one to use?
It is indeed an important decision to make. Technically both languages are supposed to work just fine so selecting one won't make any difference. However, there is a catch.
Assembly language is very specific and a bit complicated. Being a low level language, it is not easily understandable at first sight but being very specific, it gives you total control over what you do. You can even determine the total machine cycles of the whole code you have written. You can call each register by name and store / manipulate values in it or you can generate exact time delays by using simple statements.
C language is not so specific and gives you freedom to program free hand and forget about the names specific to some device. You can start writing code in your natural way and the compiler will take care of the internal operations for you. This makes things a lot more easier as compared to Assembly Language. However, we can never know about the machine cycles executed by a single C statement as it is entirely dependent on the compiler you use.
My opinion? As a beginner with 8051, you must play only with Assembly Language so as to understand the flow of a code in the hardware sense. In fact, this practise will get you familiar with many aspects of the 8051 microcontroller and how to manipulate it efficiently. But once you get the hold of it you will realize that it is time consuming and that's where you jump to C language.
hw can i learn embedded C language ???, whr i can get it.!!
ReplyDeleteYou need to get familiar with C language first and after getting hold of it, you can move to embedded C language and you will see that there is not much difference. You just have to know about the particular microcontroller architecture for writing a program code for it.
DeleteAs far as the 8051 microcontroller is concerned, you can use the book
"The 8051 Microcontroller and Embedded. Systems. Using Assembly and C"
By Muhammad Ali Mazidi and Janice Gillispie Mazidi
which is an excellent reference for getting introduced to embedded C language for the 8051 microcontroller.
is it available inthe net
ReplyDeleteYes. I am sure it's available.
Delete