C Program Microcontroller 8051
Embedded C ProgrammingEarlier, many embedded applications were developed using assembly level programming. However, they did not provide portability. This disadvantage was overcome by the advent of various high level languages like C, Pascal, and COBOL. However, it was the C language that got extensive acceptance for embedded systems, and it continues to do so. The C code written is more reliable, scalable, and portable; and in fact, much easier to understand.
C Program Microcontroller 8051 Tutorial
About C LanguageC language was developed by Dennis Ritchie in 1969. It is a collection of one or more functions, and every function is a collection of statements performing a specific task.C language is a middle-level language as it supports high-level applications and low-level applications. Before going into the details of embedded C programming, we should know about RAM memory organization.
Salient features of the language. C language is a software designed with different keywords, data types, variables, constants, etc. Embedded C is a generic term given to a programming language written in C, which is associated with a particular hardware architecture.
Embedded C is an extension to the C language with some additional header files. These header files may change from controller to controller. The #include is used.The embedded system designers must know about the hardware architecture to write programs. These programs play prominent role in monitoring and controlling external devices. They also directly operate and use the internal architecture of the microcontroller, such as interrupt handling, timers, serial communication and other available features. Differences between C and Embedded C Differences between C and Embedded C The basic additional features of the embedded softwareData types.
The data type refers to an extensive system for declaring variables of different types like integer, character, float, etc. The embedded C software uses four data types that are used to store data in the memory.The ‘char’ is used to store any single character; ‘int’ is used to store integer value, and ‘float’ is used to store any precision floating point value.The size and range of different data types on a 32-bit machine is given in the following table. The size and range may vary on machines with different word sizes. Data typesKeywordsThere are certain words that are reserved for doing specific tasks. These words are known as keywords. They are standard and predefined in the Embedded C.Keywords are always written in lowercase.
These keywords must be defined before writing the main program. Bluestack for windows 7 ultimate.
8051 Microcontroller8051 Microcontrollers are a basic, primitive controller which every embedded engineer should learn. Even though there are many modern microcontrollers the 8051 still holds its significance due to its capability to develop complex systems using it.
8051 Microcontroller Ppt
This tutorial focuses on covering the basics of 8051 microcontroller and will give you clear idea about how to use ports, how to load values into and how to make controller work per your requirements.This article will only cover the basics concepts needed to program the 8051 Microcontroller. It is advised to refer a book for detailed explanation of 8051 Microcontroller. REGISTERS:registerRegisters are small memory element in a Microcontroller where a specific value can be loaded to perform a specific task. It can vary in size such as 8-bit or 16-bit registers, but in 8051 register we generally use only 8 bit registers. The LSB marks the initial or Least significant bit and MSB marks the last or Most significant bit. HEX VALUES IN MICROCONTROLLER:Hex valuesIn Microcontrollers we use hex values to represent the data fed into it because of its simplicity in representation and easier understanding. For example if we have a 8bit data such as 0000 1111 it is easier to represent it as 0F (Refer the above table).
In 8051 Microcontrollers we used hex values to load values into any register or port. And it is represented as 0x0F. Whereas the “0x” stands for using data in the hex format. ACCESSING 8051 PORTS:There are several ways of using the ports of a Microcontroller and you can use any method which fits you with ease considering the flexibility of the code.SBIT – Single bit which was used to define a specific pin or bit in the port of a 8051 microcontroller. Say for example if you need to access Pin 5 of the Port 0 in your 8051 Controller you must give it assbit led=P0^5where led is the name assigned by the user which can be altered for your readability.SFR- Special function registers are the registers which are accessed by means of its address. The address of the ports in the 8051 controller is given below.PORT 0 – 0x80PORT 1 – 0x90PORT2 – 0xA0PORT3 – 0xB0To access Port 1 using SFR we should give it assfr led=0x90Where led is the name assigned by the user which can be altered for your readability. Whereas the Ports of the Microcontroller can also be accessed by means of the Port numbers.
For example you need to access Port 2, you can mention it as “P2”Lets see a Sample code to give you a clear idea about the basic 8051 Programming.