1 / 97

Introduction to Embedded Systems

Introduction to Embedded Systems . Rabie A. Ramadan rabieramadan@gmail.com http:// www.rabieramadan.org /classes/2014/embedded/ 8. Microcontrollers . A microcontroller is a kind of miniature computer that found in all kinds of gizmos

brook
Download Presentation

Introduction to Embedded Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Embedded Systems Rabie A. Ramadan rabieramadan@gmail.com http://www.rabieramadan.org/classes/2014/embedded/ 8

  2. Microcontrollers

  3. A microcontroller is a kind of miniature computer that found in all kinds of gizmos Generally speaking, if a device has buttons and a digital display, chances are it also has a programmable microcontroller brain. What is a Microcontroller?

  4. Microcontrollers are 'single chip' computers specifically designed to: Read input devices, such as buttons and sensors Process data or information Control output devices, such as lights, displays, motors and speakers Microcontrollers cont.

  5. Microcontrollers are placed in devices, or embedded, for operation and control. Can you name other devices in your life that have embedded control? Embedded Control

  6. A microprocessoris the “brain” of a computer system Generally referred to as the central processing unit (CPU), the microprocessor by itself is practically useless To be useful, one must have means of communicating with it using input and output devices One must also add memory (ROM and RAM) so that the system can be programmed. Microprocessor vs. Microcontroller

  7. A microcontrolleris a computer chip designed for control-oriented applications Unlike ordinary microprocessors, microcontrollers have built-in features that make them operate almost independent of additional circuitry This is possible because microcontrollers contain things like memory (ROM, EPROM, RAM, etc) input and output ports timers serial and parallel communication capability analog-to-digital converters Microprocessor vs. Microcontroller Cont.

  8. The BASIC Stamp embeds a microcontroller, the PIC16C57, on a module to make programming and use very simple, yet very powerful. Additional components on the module provide everything needed to systems and applications, like robotics. The BASIC Stamp

  9. Microcontroller • There are two branches in the ongoing evolution of the microprocessor. • CPUs for the personal computer and workstation industry, where the main constraints are high speed and large word size (32 and 64 bits) • Development of the microcontroller, which is a single IC containing specialized circuits and functions that are applicable to mechatronic system design. • Examplesof microcontrollers are Microchip’s PIC, Motorola’s 68HC11, and Intel’s 8096

  10. Microcontrollers • Factors that have driven development of the microcontroller: • low cost, • versatility, • ease of programming, • and small size. • Used in a wide array of applications including: • Home appliances, • entertainment equipment, • telecommunication equipment, • automobiles, trucks, airplanes, toys, and office equipment.

  11. typical full-featured microcontroller

  12. Microcontroller programming Microcontroller manufacturers offer programming devices that can download a compiled machine code file from a PC directly to the EEPROM of the microcontroller, usually via the PC serial port and special-purpose pins on the microcontroller. These pins can usually be used for other purposes once the device is programmed.

  13. Microcontroller I/O The digital I/O ports allow binary data to be transferred to and from the microcontroller using external pins on the IC. These pins can be used to read the state of switches and on-off sensors, to interface to external analog-to-digital and digital-to-analog converters, to control digital displays, and to control on-off actuators. The I/O ports can also be used to transmit signals to and from other microcontrollersto coordinate various functions.

  14. Microcontroller communication Standards • There are various standards or protocols for serial communication : • SPI (serial peripheral interface), • I2C (inter-integrated circuit), • UART (universal asynchronous receiver-transmitter), • and USART (universal synchronous asynchronous receiver-transmitter).

  15. Microcontroller capabilities microcontroller clock speeds are slower than those used for microcomputers. For some applications, a selected microcontroller may not have enough speed or memory to satisfy the needs of the application Fortunately , microcontroller manufacturers usually provide a wide range of productsto accommodate different applications. When more memory or I/O capability is required, the functionality of the microcontroller can be expanded with additional external components

  16. PIC PICis an acronym for peripheral interface controller The phrase Microchip uses to refer to its line of microcontrollers. Microchipoffers a large and diverse family of low-cost PICproducts.

  17. Class Discussion

  18. PIC16F84 Properties • The PIC16F84 is: • an 8-bit CMOS microcontroller where data bus is 8 bits wide • 1792 bytes of flash EEPROM program memory, • The 1792 bytes of program memory are subdivided into 14-bit words, because machine code instructions are 14 bits wide. • 68 bytes of RAM data memory, • 64 bytes of non-volatile EEPROM data memory. • can be driven at a clock speed up to 10 MHz but is typically driven at 4 MHz

  19. Watch Dog Timer A useful special purpose timer It is a count-down timer that, when activated, needs to be continually reset by the running program. If the program fails to reset the watch-dog timer before it counts down to 0, the PIC will automatically reset itself. In a critical application, you might use this feature to have the microcontroller reset if the software gets caught in an unintentional endless loop

  20. The PIC16F84 is packaged on an 18-pin that has the pin schematic

  21. Pin Naming 13 I/O lines, called bidirectional lines because each can be individually configured in software as an input or output.

  22. The program is written and uploaded into microcontroller If the program is written in assembly language, the PC must have software called a cross-assembler that generates machine code for the microcontroller

  23. PIC programs can be written in a form of BASIC called PicBasic Pro. The PicBasic Pro complier can compile these programs, producing their assembly language equivalents, assembly code can then be converted to hexadecimal machine code (hex code) that can be downloaded directly to the PIC flash EEPROM through a programming device attached to a PC.

  24. PICBasic Example

  25. The Previous Example using the concept of Polling • For more complex applications, polling may not be suitable • An alternative approach is to use an interrupt. • some inputs are connected to special input lines, designated as interrupts. • To detect interrupts, two specific registers on the PIC must be initialized correctly. • the option register (OPTION_REG) and • the interrupt control register (INTCON).

  26. More details on the PIC16F84 http://highered.mcgraw-hill.com/sites/dl/free/0072402415/55328/alc_ch07.pdf

  27. Choosing a microcontroller

  28. Criteria for choosing a microcontroller Features of the 8051

  29. Comparison of 8051 Family Members

  30. The 8051 Microcontroller architecture

  31. Meeting the computing needs of the task efficiently and cost effectively speed, the amount of ROM and RAM, the number of I/O ports and timers, size, packaging, power consumption easy to upgrade cost per unit Availability of software development tools assemblers, debuggers, C compilers, emulator, simulator, technical support Wide availability and reliable sources of the microcontrollers. Three criteria in Choosing a Microcontroller

  32. AHarvard architecture (separate instruction/data memories) Single chip microcontroller (µC) Developed by Intel in 1980 for use in embedded systems. Today largely superseded by a vast range of faster and/or functionally enhanced 8051-compatible devices manufactured by more than 20 independent manufacturers The 8051 microcontroller

  33. Block Diagram External interrupts On-chip ROM for program code Timer/Counter Interrupt Control Timer 1 On-chip RAM Counter Inputs Timer 0 CPU Serial Port Bus Control 4 I/O Ports OSC P0 P1 P2 P3 TxD RxD Address/Data

  34. Feature8051 8052 8031 ROM (program space in bytes) 4K 8K 0K RAM (bytes) 128 256 128 Timers 2 3 2 I/O pins 32 32 32 Serial port 1 1 1 Interrupt sources 6 8 6 Comparison of the 8051 Family Members

  35. Vcc P1.0 1 40 P0.0(AD0) P1.1 2 39 P0.1(AD1) P1.2 3 38 P0.2(AD2) P1.3 4 37 8051 (8031) P0.3(AD3) P1.4 5 36 P0.4(AD4) P1.5 6 35 P0.5(AD5) P1.6 7 34 P0.6(AD6) P1.7 8 33 P0.7(AD7) RST 9 32 (RXD)P3.0 EA/VPP 10 31 (TXD)P3.1 ALE/PROG 11 30 PSEN (INT0)P3.2 12 29 P2.7(A15) 13 28 (INT1)P3.3 (T0)P3.4 P2.6(A14) 14 27 (T1)P3.5 P2.5(A13) 15 26 P2.4(A12) (WR)P3.6 16 25 P2.3(A11) (RD)P3.7 17 24 P2.2(A10) XTAL2 18 23 P2.1(A9) XTAL1 19 22 P2.0(A8) GND 20 21 Pin Description of the 8051 

  36. Vcc(pin 40): Vcc provides supply voltage to the chip. The voltage source is +5V. GND(pin 20):ground XTAL1 and XTAL2(pins 19,18): These 2 pins provide external clock. Way 1:using a quartz crystal oscillator Way 2:using a TTL oscillator Pins of 8051(1/4)

  37. RST(pin 9):reset It is an input pin and is active high(normally low). The high pulse must be high at least 2 machine cycles. It is a power-on reset. Upon applying a high pulse to RST, the microcontroller will reset and all values in registers will be lost. Reset values of some 8051 registers Way 1:Power-on reset circuit Way 2:Power-on reset with debounce Pins of 8051(2/4)

  38. /EA(pin 31):external access There is no on-chip ROM in 8031 and 8032 . The /EA pin is connected to GND to indicate the code is stored externally. /PSEN & ALE are used for external ROM. For 8051, /EA pin is connected to Vcc. “/” means active low. /PSEN(pin 29):program store enable This is an output pin. Pins of 8051(3/4)

  39. ALE(pin 30):address latch enable It is an output pin and is active high. 8051 port 0 provides both address and data. The ALE pin is used for de-multiplexing the address and data by connecting to the G pin of the 74LS373 latch. I/O port pins The four ports P0, P1, P2, and P3. Each port uses 8 pins. All I/O pins are bi-directional. Pins of 8051(4/4)

  40. Using a quartz crystal oscillator We can observe the frequency on the XTAL2 pin. Figure 4-2 (a). XTAL Connection to 8051 

  41. Using a TTL oscillator XTAL2 is unconnected. XTAL2 NC EXTERNAL OSCILLATOR SIGNAL XTAL1 GND XTAL Connection to an External Clock Source 

  42. The 8051 has four I/O ports Port 0 (pins 32-39):P0(P0.0~P0.7) Port 1(pins 1-8):P1(P1.0~P1.7) Port 2(pins 21-28):P2(P2.0~P2.7) Port 3(pins 10-17):P3(P3.0~P3.7) Each port has 8 pins. Named P0.X (X=0,1,...,7), P1.X, P2.X, P3.X These 8 bits form a byte. Each port can be used as input or output (bi-direction). Pins of I/O Port 

  43. Most 8051 instructions are executed in one cycle. MUL (multiply) and DIV (divide) are the onlyinstructions that take more than two cycles to complete (four cycles) Normally two codebytes are fetched from the program memory during every machine cycle. The only exception to thisis when a MOVX instruction is executed. MOVX is a one-byte, 2-cycle instruction that accessesexternal data memory. CPU timing

  44. 8051 microcontroller features

  45. 8051 microcontroller instruction set

  46. Data Transfer Instructions

  47. Bit and Byte Manipulations and Logic instructions

More Related