Sunday, October 16, 2011

Details on various components of embedded System.

After talking much about what embedded system is ? I want to go in detail for various components of embedded system.

Micro-controllers
Wikipedia says that: A microcontroller (sometimes abbreviated µC, uC or MCU) is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM.
A microcontroller is a single chip VLSI unit which though having computational capabilities, possesses enhanced input output capabilities and a number of on-chip functional units  


Micro-controllers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications.

A microcontroller is a single integrated circuit with following features:


1. Processors.
2. Internal RAM.
3. Timers and Watch dog timers.
4. External Memories interface.
5. Interrupt controller.
6. Internal flash/ROM.
7. Ports
     i) I/O ports control and Interfaces/Drivers.

    ii) Serial UART communication Port.
   iii) Serial Synchronous Communication Port.
8. Application specific circuits in Specific versions.
     i) DMA controller.
    ii) Network driver stack and interfaces.
   iii) A/D Converter.
   iv) CAN controller.
   v) PWM circuit for D/A.
  vi) Print Controller.

  vii) Modem.
 viii) DTMF circuit.
.

A microcontroller is used when a small or part of the embedded software has to be located in the internal memory and when on-chip functional units such as the interrupt handler, port, timer, ADC, PWM and CAN controller are required.

 Processor
The processor (called CPU, for Central Processing Unit) is an electronic circuit that operates at the speed of an internal clock thanks to a quartz crystal that, when subjected to an electrical currant, send pulses, called "peaks". The clock speed (also called cycle), corresponds to the number of pulses per second, written in Hertz (Hz). Thus, a 400 MHz computer has a clock that sends 400,000,000 pulses per second.

With each clock peak, the processor performs an action that corresponds to an instruction or a part thereof. A measure called CPI (Cycles Per Instruction) gives a representation of the average number of clock cycles required for a microprocessor to execute an instruction. A processor power can thus be characterized by the number of instructions per second that it is capable of processing. MIPS (millions of instructions per second) is the unit used and corresponds to the processor frequency divided by the CPI.


What is Instruction ?


An instruction is an elementary operation that the processor can accomplish. Instructions are stored in the main memory, waiting to be processed by the processor. An instruction has two fields:
  • the operation code, which represents the action that the processor must execute;
  • the operand code, which defines the parameters of the action. The operand code depends on the operation. It can be data or a memory address.

The number of bits in an instruction varies according to the type of data (between 1 and 4 8-bit bytes).
Instructions can be grouped by category, of which the main ones are:
  • Memory Access: accessing the memory or transferring data between registers.
  • Arithmetic Operations: operations such as addition, subtraction, division or multiplication.
  • Logic Operations: operations such as AND, OR, NOT, EXCLUSIVE NOT, etc.
  • Control: sequence controls, conditional connections, etc.
 When these instructions are executed the data is temporarily stored into small small, local memory locations of 8, 16, 32 or 64 bits called registers. The number of registers depend upon type of processor.



The main registers are:
  • the accumulator register (ACC), which stores the results of arithmetic and logical operations;
  • the status register (PSW, Processor Status Word), which holds system status indicators (carry digits, overflow, etc.);
  • the instruction register (RI), which contains the current instruction being processed;
  • the ordinal counter (OC or PC for Program Counter), which contains the address of the next instruction to process;
  • the buffer register, which temporarily stores data from the memory.
We will go in more detail about processors when I will solely write about microprocessors.


 Internal RAM
 Internal RAM (IRAM) is the address range of RAM that is internal to the CPU. This memory is internal to CPU and is SRAM.




Watch dog timers
A watchdog timer (WDT) is a device or electronic device that performs a specific operation after a certain period of time if something goes wrong with an electronic system and the system does not recover on its own.

A common problem is for a machine or operating system to lock up if two parts or programs conflict, or, in an operating system, if memory management trouble occurs. In some cases, the system will eventually recover on its own, but this may take an unknown and perhaps extended length of time. A watchdog timer can be programmed to perform a warm boot (restarting the system) after a certain number of seconds during which a program or computer fails to respond following the most recent mouse click or keyboard action. The timer can also be used for other purposes, for example, to actuate the refresh (or reload) button in a Web browser if a Web site does not fully load after a certain length of time following the entry of a Uniform Resource Locator (URL).

A WDT contains a digital counter that counts down to zero at a constant speed from a preset number. The counter speed is kept constant by a clock circuit. If the counter reaches zero before the computer recovers, a signal is sent to designated circuits to perform the desired action.

Interrupt controller
A special-purpose integrated circuit that functions as an overall manager in an interrupt driven system. It accepts requests from the peripheral equipment, determines which of the incoming requests is of the highest priority, ascertains whether the incoming request has a higher priority value than the level currently being serviced, and issues an interrupt to the CPU based on this determination.

PICs typically have eight interrupt lines, and two PICs are often cascaded to provide 15 available interrupt lines.


Internal Flash
It is non volatile computer storage chip that can be electrically erased and programmed. Data can be written in small chunks but erasing is done block by block. This memory is created from E2PROM but is different from E2PROM in the way FLASH is erased.

Ports
These ports used for transferring data or receiving inputs from some input device. These are used for communication it could be a asynchronous communication or it could be synchronous.    

Application specific circuits in Specific versions
Under this heading I will be explaining few components.
 
DMA controllers:
Direct Memory Access (DMA) is one of several methods for coordinating the timing of data transfers between an input/output (I/O) device and the core processing unit or memory in a computer. DMA is one of the faster types of synchronization mechanisms, generally providing significant improvement over interrupts, in terms of both latency and throughput. An I/O device often operates at a much slower speed than the core. DMA allows the I/O device to access the memory directly, without using the core. DMA can
lead to a significant improvement in performance because data movement is one of the most common operations performed in processing applications. The DMA unit contains the necessary counters, offset registers, and pointers to transparently handle one-, two-, and three-dimensional data matrix transfers. These
registers can be given values that result in special addressing modes, for example, access to circular buffers and linear buffers with non-unit stride. The data structure dimensionality can be chosen independently for the source access versus the destination access involved in the data moves.

To be continued ........

Sunday, September 25, 2011

Introduction




What is Embedded system: 

This basic question comes to our mind when we hear word Embedded system. I know that you too love embedded as I do that is why you are here.

Embedded Systems is a special purpose computer system/board, which encapsulates all the devices such as processor, memory, interface and control in single package or board to perform only a specific application tasks.

You will think that my desktop or my Laptop can also do specific task if I program them for the same. Yes you are correct they can do but can you imagine your desktop sitting on microwave and baking pizza for you or can you see your laptop connected with your car/motor bike engine and monitoring it when you are riding on air. Now a days what ever gadget you see you can think of embedded systems sitting inside it and performing special tasks for you and making your life easy.

The various general examples from our day to day life are:

1. Digital camera.
2. LCD, LED or any TV.
3. DVD players
4. Microwave oven.
5. Washing machine.
5. Mobile phones
6. Car and Motorcycle.
7. Refrigerator.
8. Medical equipments.
9. Video game consoles.
10. Security application.

These are only few general life examples which we find around us. The field of use for embedded systems is very vast.

If you have some what knowledge of electronics and if you open any of embedded systems equipment or gadget you will see that it is very small unit but it is not much simple as of its size. It comprises of Various Components.

If we go by the definition which I have given above then it is comprised of following components.

1. Processor
2. Memory (On-chip and Off-chip)
3. Actuators
4. Sensors
5. Converters
6. Communication path with environment


We will learn about them in detail one by one but before that I want to finish my definition first. Something which is missing in that definition is that it says nothing about software embedded inside memory of the unit. Is discussion about software obvious ?

Yes it is as it contains all the logic and instructions to be given to the components mentioned above. If all these components constitute the body of embedded systems then software is the soul. So now we can broadly divide embedded system in two parts

1. Hardware
2. Software.

Hardware comprises of all the components listed above.

So our new definition becomes.   

An embedded system is combination of hardware and software designed to perform dedicated function. This embedded system could be an independent single unit or it could be a part of larger system.
 OR
An embedded system is a system that has embedded software and computer-hardware,which makes it a system dedicated for an application(s) or specific part of an application or product or a part of larger system.

Tim Wilmshurst author of An introduction to Design of small scale Embedded Systems with examples from PIC, 80C51 and 68HC05/08 micro-controllers:
An embedded system is a system whose principal function is controlled by a computer embedded within it. The computer is likely to be micro-controller or microprocessor. The word embedded implied that it lies inside the overall system , hidden from view, forming an integral part of[the] greater whole. 

Component of General purpose Computer

A computer is a system that has the following or more components.
1. A microprocessor.
2. A large memory of the following two kinds:

   (a) Primary memory(semiconductor memories)
       i) Random Access memory RAM.
      ii) Read only memory ROM.
     iii) Fast accessible caches.

   (b) Secondry memory
       i) Magnetic memory located in Hard disks, diskettes and cartridge tapes.
      ii) Optical memory in CD-ROMs or memory sticks(in mobile computers)
          using which different users can be loaded into the primary memory and run
3. IO units such as touch screen, modem fax cum modem etc.
4. Input unit such as keyboard, mice digitizer, scanner, etc.
5. Output unit such as an LCD screen, video monitor , printer etc.
6. Networking unit such as and Ethernet  card front-end processor-based server, bus drivers
7. An Operating system that has general purpose user and application software in the secondary memory.

An embedded system is system that has three component embedded into it:
1. It embeds hardware similar to a computer. Figure below shows the units in the hardware of an embedded system: As its software usually embeds in the ROM or flash memory, it usually do not need a secondry hard disk and CD ROM as in a computer.
2. It embeds main application software. The application software may concurrently perform a series of tasks
 or processes or threads.
3. It embeds a real time operating system RTOS that supervises the application software running on hardware and organizes access to a resource according to priorities of the task in the system. It provides a mechanism to let the run a process as scheduled and context-switch between the various process.  

Characteristics.
An embedded system is characterized by trhe following:
1.Real-time and multirate operations define the ways in which the works and reacts to events, interrupts or schedules the system's functioning in real time. It does so by following a plan to control latencies and to meet deadlines.(Latency refers to waiting period between running the codes of task or interrupt service routine and instance at which the need for the task or interrupt service routine and the instance at which the need for the task or interrupt from an event arises). The different operation may take place at distinct rates. For example, audio, video, data, network stream and events have different rates and time constraints.
2.Complex algorithms
3.Complex graphic user interfaces and other user interfaces.
Dedicated Functions.

Constraints:
An embedded system is designed keeping in view three constraints
1. Available system-memory
2. Available processor speed
3. The need to limit power dissipation when running the system continuously in cycles of 'wait for events','run','stop','wake-up'  and sleep.
The system design or an embedded system has constraints with regard to performance, power, size and design and manufacturing costs.

An embedded system is typically required to meet very different requirements than a general purpose personal computer. We can also get our task done with general purpose computer system but the difference lies in cost and power consumption. There are various characteristics which are common to every embedded system.

1. Low cost
2. Low power.
3. Higher performance.
4. Real time property.

Classification of embedded system.
1. Small scale embedded sytem.
2. Medium scale embedded system.
3. Sophisticated embedded system.

Small scale embedded system.
1. 8 bit or 16 bit micro-controller.
2. Hardware and software complexity is small.
3. Usually developed in  c or assembly.
4. System keeps on running continuously.

Programming tools: editor, assembler and cross assembler.

Medium scale embedded system.
1. 16 or 32 bit micro-controller.
2. Digital signal processors ( DSP ).
3. Reduced instruction set ( RISC ).
4. Hardware and software complexity.

Programming tools: RTOS, Source code engineering tools, Simulator, debugger and IDE.

Sophisticated Embedded system.
1. Enormous hardware and software complexity.
2. These may need several several IPs and ASIPs, scalable processors or configurable processors
and programmable logic arrays.
3. They are used for cutting age applications that need hardware and software co-design and components that have to be integrated in the final system.
4. They are constrained by the processing speeds available in their hardware units.

Programing tools: For these systems programing tools may not be available at a reasonable cost or may  not be completely available.