The use of C language to program microcontrollers is becoming too common. And most of the time its not easy to buld an application in assembly which instead you can make easily in C. So It’s important that you know C language for microcontroller which is commonly known as Embedded C. As we are going to use Keil C51 Compiler, hence we also call it Keil C.
Embedded system encompasses a variety of hardware and software components, which perform specific functions in host systems. Embedded systems have become increasingly digital with a non-digital periphery and therefore, both hardware and software co-design is relevant. Majority of computers are used in such systems to distinguish them from standard main frames, workstations and pc’s. Advances in microelectronics have made possible applications that would have been impossible without an embedded system design.
Embedded system applications have virtually entered every sphere of our lives embedded systems cover a broad of products that generalization is difficult.
An embedded system is a microprocessor- based system that is incorporated into a device to monitor and control the functions of the components of the device. They are used in many devices. Developments in microelectronics, processor speeds and memory elements have resulted in power embedded systems with a number of applications.
This paper seeks differences between embedded computer design and desktop design, which also presents design challenges.
An embedded system is a type of computer system or computing device, which performs a dedicated function and/or is designed for use with a specific embedded software application.
COMPONENTS OF AN EMBEDDED SYSTEM:
Embedded systems have the following components.
A processor fetches instructions from the memory unit and executes the instructions. An instruction consists of an instruction code and the operands on which the instruction should act upon. The format of instruction code and operands of a processor is defined by the processor’s instruction set. Each type of processor has its own instruction set. Performance of the system can be improved by dedicated processors, which implement algorithms in hardware using building blocks such as hardware counters and multipliers.
Some embedded processors have special fuzzy logic instructions. This is because inputs to an embedded system are sometimes better represented as fuzzy variables. For instance, the mathematical model for a control system may not exist or may involve expensive computing power. Fuzzy logic can be employed for such control systems to provide a cost-effective solution.
The memory unit in an embedded system should have low access time and high density. (A memory chip- has greater density if it can store more bits in the same amount of space. Memory in an embedded system consists of ROM and RAM .The contents of ROM are non-volatile while RAM is volatile. ROM stores the program code while RAM is used to store transient input or output data. Embedded systems generally do not possess secondary storage devices such as magnetic disks. As programs of embedded systems are small there is no need of virtual storage.
Peripherals are input and output devices connected to the serial and parallel ports of the embedded system. Serial port transfers one bit at a time between the peripheral and themicroprocessor. Parallel ports transfer an entire word consisting of many bits simultaneously between the peripheral and the microprocessor.
Programmable interface devices that act as an interface between microprocessor with peripherals provide flexibility since they can be programmed to perform I/O on different peripherals. The microprocessor monitors the inputs from peripherals and performs actions when certain events occur. For instance, when sensors indicate the level of water in the washtub of a washing machine is above the present level, the microprocessor starts the wash cycle.
Introduction to the Keil 8051 ‘C’ Compiler
We will use the Keil ‘C’ cross compiler to develop our 8051 programs.
The Keil ‘C’ Compiler Directory Structure is as follows
\BIN : This contains the compiler .exe files
\INC : This contains the header files
\LIB : This contains the object libraries
\WORKING : All user programs reside here
\A51 : Assembler directory used by comp
The C programming language was designed for computers, though, and not embedded systems. It does not support direct access to registers, nor does it allow for the reading and setting of single bits, two very important requirements for 8051 software. In addition, most software developers are acustomed to writing programs that will by executed by an operating system, which provides system calls the program may use to access the hardware. However, much code for the 8051 is written for direct use on the processor, without an operating system. To support this, the Keil compiler has added several extensions to the C language to replace what might have normally been implemented in a system call, such as the connecting of interrupt handlers.
The purpose of this manual is to further explain the limitations of the Keil compiler, the modifications it has made to the C language, and how to account for these in developing software for the 8051 microcontroller.