PROCESSORS & CONTROLLERS

Slides:



Advertisements
Similar presentations
Parul Polytechnic Institute
Advertisements

The 8051 Microcontroller and Embedded Systems
Autumn 2012C.-S. Shieh, EC, KUAS, Taiwan1 The 8051 Family Microcontroller Chin-Shiuh Shieh Department of Electronic Engineering.
8051 Core Specification.
Interfacing of 8051 UNIT 4.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
Engineering 4862 Microprocessors Lecture 26 Cheng Li EN-4012
Microcontroller 8051.
Embedded Systems UNIT 3. Pin Details of 8051 Pins 1-8: Port 1 Each of these pins can be configured as an input or an output. Pin 9: The positive voltage.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
The 8051 Microcontroller architecture
UNIT V INTERFACING MICROCONTROLLER
The 8051 Microcontroller and Embedded Systems
CHAPTER TIMER PROGRAMMING Timers The 8051 has two timers/counters, they can be used as ◦ Timers to generate a time delay ◦ Event counters.
8051 timer/counter.
1 Chapter 4 Timer Operation (I. Scott MacKenzie).
CoE3DJ4 Digital Systems Design Chapter 4: Timer operation.
Lecture Set 9 MCS-51 Serial Port.
CoE3DJ4 Digital Systems Design Chapter 6: Interrupts.
Serial Communication Lec note 9.
Timers /Counters Programming  The 8051 has 2 timers/counters: ○ timer/counter 0 ○ timer/counter 1 They can be used as 1. The timer is used as a time.
1. Registers Used in Timer/Counter  TH0, TL0, TH1, TL1  TMOD (Timer mode register)  TCON (Timer control register) 2.
8051 Timer/Counter Lec note 7.
8051 Micro controller. Architecture of 8051 Features of 8051.
Microcontrollers Class : 4th Semister E&C and EEE Subject Code: 06ES42
Intel 8051 Another family of microcontroller is the Intel 8051 family. The basic 8051 microcontroller has four parallel input/output ports, port 0, 1,
Jump, Loop, and Call Instructions
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
kashanu.ac.ir Microprocessors Interrupts Lec note 8.
Timer Programming in Assembly and C Prepared By:
HJD Institute of Technical Education & Research- Kera(Kutch) The 8051 Microcontroller architecture PREPARED BY: RAYMA SOHIL( )
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
Serial I/O Port.
Assembly Language * * * * * * * 8051 Timer
Source: Serial Port Source:
8051 Timers Timers are the peripherals of the 8051 Microcontroller.
SERIAL PORT PROGRAMMING
Microcontroller Bharat Sankhlecha
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Parallel Port Interfacing
E3165 DIGITAL ELECTRONIC SYSTEM
Introduction to Micro Controllers & Embedded System Design Interrupt
UNIT 5 TIMRERS/COUNTERS
Introduction to Micro Controllers & Embedded System Design I/O Processing and Serial Port Operation Department of Electrical & Computer Engineering Missouri.
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
* * * * * * * 8051 Interrupts Programming.
EMT 348: Microcontroller Timer/counter
Source: Serial Port Source:
Introduction to Micro Controllers & Embedded System Design Timer Operation Department of Electrical & Computer Engineering Missouri University of Science.
Timer.
(Electrical Engg 6th Semester)
The 8051 Microcontroller (8 bit )
Microcontroller 8051 Made By: Arun Branch. 4th Sem. I&C Engg.
8051 Microcontroller.
Timer Source: under
Interrupt Source: under
First Design Key board R L S.
Interrupt.
UNIT-VIII 8051 Microcontroller Architecture Register set of 8051
Interrupt Source: under
The 8051 Microcontroller (8 bit )
Source: Serial Port Source:
Timer Source: under
8253 – PROGRAMMABLE INTERVAL TIMER (PIT). What is a Timer? Timer is a specialized type of device that is used to measure timing intervals. Timers can.
Compiled by Dr. N.Shanmugasundaram, HOD, ECE Dept, SECE.
Interrupts of 8051 Introduction 8051 Interrupt organization
Source: Serial Port Source:
8051SERIAL PORT PROGRAMMING
Presentation transcript:

PROCESSORS & CONTROLLERS Course code : 15 EM 2202 L – T – P : 2 – 2 – 2 Pre Requisite : 15 EC 1101 Credits : 4

PROCESSORS AND CONTROLLERS 8086 Microprocessor: Introduction to Microprocessor, Intel Microprocessor families ,8086 Microprocessor architecture, Register Organization, Pin Description, Physical Memory Organization, Modes of operation. 8086 Instruction set & Assembly Language programming: Addressing modes, Instruction set, Assembler directives, simple Programs, Procedures and Macros, 8086 Interrupts.

PROCESSORS AND CONTROLLERS 8051 Microcontroller: Microcontroller families, 8051 Architecture, Signal Description, Register organization, Internal RAM, Special Function Registers, Interrupt control flow, Timer/Counter Operation, Serial Data Communication, and RS-232C Standard.8051 Programming & Interfacing: Addressing modes, Instruction set, Simple Programs involving Arithmetic and Logical Instructions, Timers/Counters, Serial Communication & Interrupts.

PROCESSORS AND CONTROLLERS PIC Microcontroller: Introduction, Architectural overview, Memory organization, interrupts and reset, I/O ports, Timers. Interfacing: Matrix Key Board, Stepper Motor, LCD’s, DAC & ADC. using 8051 and PIC Microcontroller.

Microcontroller 8051

TIMERS The 8051 has two timers: TIMER 0 TIMER 1

TMOD Register Gate : When set, timer only runs while INT(0,1) is high. C/T : Counter/Timer select bit. M1 : Mode bit 1. M0 : Mode bit 0.

TCON Register (BIT ADRESSABLE REG) TCON.7 - TF1: Timer 1 overflow flag. TCON.6 - TR1: Timer 1 run control bit. TCON.5 - TF0: Timer 0 overflag. TCON.4 - TR0: Timer 0 run control bit. TCON.3 - IE1: External interrupt 1 edge flag. TCON.2 - IT1: External interrupt 1 type flag. TCON.1 - IE0: External interrupt 0 edge flag. TCON.0 - IT0: External interrupt 0 type flag.

Concept of timer

GATE Control in TMOD If GATE = 1, the start and stop of the timer are done externally through pins P3.2 and P3.3 for timers 0 and 1, respectively

COUNTER Programming

Mode 1 Programming Load the TMOD value register indicating which timer (Timer0 or Timer1) is to be used and which timer mode is selected. Load registers TL & TH with initial count values. Start the timer Keep monitoring the timer flag(TF) Stop the timer. Clear TF for next round . Go back to step 2 to load TH & TL again NOTE: MODE 0 is exactly like mode-1 except that it is 13-bit timer instead 16-bit. The 13-bit timer/counter can hold values between 0000H to 1FFFH in TH-TL.

Mode 2 Programming Load the TMOD value register indicating which timer (Timer0 or Timer1)is to be used, and select the timer mode (mode-2). Load the TH register with the initial count value. Start the timer. Keep monitoring TF timer flag After it becomes “1” then clear the TF flag Go back to step 4 , since mode 2 is auto - reload

Example program for Mode1 ORG 0H MOV TMOD,#00000001B BACK: MOV TL0,#0F0H MOV TH0,#0FFH CPL P1.0 ACALL DELAY SJMP BACK DELAY:SETB TR0 HERE: JNB TF0, HERE CLR TR0 CLR TF0 RET END

Example program for Mode2 ORG 0H MOV TMOD,#00100000B MOV TH1, #05H SETB TR1 HERE: JNB TF1, HERE CPL P2.0 CLR TF1 SJMP HERE END

Serial Communication

Serial vs. parallel Communication

Synchronous vs. Asynchronous Serial data communication uses two methods Synchronous Asynchronous There are special IC chips made by many manufacturers for serial communications. UART- universal asynchronous receiver-transmitter. USART- universal synchronous - asynchronous receiver-transmitter

Framing (Asynchronous )

SCON register

Doubling the baud rate There are two ways to increase the baud rate of data transfer in 8051. 1. Use a higher frequency crystal. 2. Change a D7-bit to 1 in the PCON register PCON Register: ( Byte addressable)

Programming 8051 to transfer data serially In programming 8051 to transfer character bytes serially, the following steps must be taken The TMOD register is loaded with the value 20H , indicating the use of Timer 1 in mode 2(8-bit auto reload) to set the baud rate The TH1 is loaded with one of the values to set the baud rate for serial data transfer( assuming XTAL= 11.0592 MHz). The SCON register is loaded with the value 50H indicating serial mode 1, where an 8-bit data is framed with start & stop bits. TR1 is SET to 1 to start Timer 1. TI is cleared when transmission is complete. The character byte to be transferred serially is written into SBUF register. TI is monitored for transmission . To transfer the next character go to step 5

Example Program for Serial Communication ORG 0H MOV TMOD,#00100000B------(20H) MOV TH1,#-3 MOV SCON,#01010000B-------(50H) SETB TR1 AGAIN:MOV A,# ” “ ACALL TRANSFER MOV A,# ”K“ MOV A,# ”L“ MOV A,# ”U“ TRANSFER: MOV SBUF,A ACALL TRANSFER HERE: JNB TI, HERE MOV A,# ” “ CLR TI ACALL TRANSFER RET SJMP AGAIN END

Interrupts

Concept behind Interrupt An interrupt is an external or internal event that interrupts the microcontroller to inform it that a device needs its service Upon activation of an interrupt, the microcontroller goes through the following steps 1. It finishes the instruction it is executing and saves the address of the next instruction (PC) on the stack 2. It also saves the current status of all the interrupts internally (i.e.: not on the stack) 3. It jumps to a fixed location in memory, called the interrupt vector table, that holds the address of the ISR 4. The microcontroller gets the address of the ISR from the interrupt vector table and jumps to it 5. Upon executing the RETI instruction, the microcontroller returns to the place where it was interrupted

Interrupts & Interrupt vectors:

Interrupt Enable Register

TCON REGISTER

LEVEL TRIGGERED INTERRUPT In level triggered interrupt to ensure the activation of the hardware interrupt at the INT ‘n’ pin, make sure that the duration of the low-level signal is around 4 machine cycles.

In edge-triggered interrupts The external source must be held high for at least one machine cycle, and then held low for at least one machine cycle The falling edge of pins INT0 and INT1 are latched by the 8051 and are held by the TCON.1 and TCON.3 bits of TCON register

Interrupt Priority register

EXAMPLE PROGRAMS Write a program that continuously get 8-bit data from P0 and sends it to P1 while simultaneously creating a square wave of 200 μs period on pin P2.1. Use timer 0 to create the square wave. Assume that XTAL = 11.0592 MHz. ORG 0000H LJMP MAIN ORG 000BH CPL P2.1 RETI ORG 0030H MAIN: MOV TMOD,#02H MOV P0,#0FFH MOV TH0,#-92 (TH0=A4H) MOV IE,#82H SETB TR0 BACK: MOV A,P0 MOV P1,A SJMP BACK END

EXAMPLE PROGRAMS Write a program to generate a square wave if 50Hz frequency on pin P1.2. Assume that XTAL=11.0592MHz ORG 0 LJMP MAIN ORG 000BH CPL P1.2 MOV TL0,#00 MOV TH0,#0DCH RETI ORG 30H MAIN: MOV TM0D,#00000001B MOV TL0,#00 MOV TH0,#0DCH MOV IE,#82H SETB TR0 HERE: SJMP HERE END

EXAMPLE PROGRAMS Write a program in which the 8051 reads data from P1 and writes it to P2 continuously while giving a copy of it to the serial COM port to be transferred serially. Assume that XTAL=11.0592. Set the baud rate at 9600 ORG 0000H ORG 100H LJMP MAIN SERIAL: JB TI,TRANS ORG 23H MOV A,SBUF LJMP SERIAL CLR RI ORG 30H RETI MAIN: MOV P1,#0FFH TRANS: CLR TI MOV TMOD,#20H RETI MOV TH1,#0FDH END MOV SCON,#50H MOV IE,#10010000B SETB TR1 BACK: MOV A,P1 MOV SBUF,A MOV P2,A SJMP BACK

LCD LCD Interfacing (16X2) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Vss Vcc VEE RS R/W EN DB0 ---------------------------------------------DB7 + - LCD 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Addresses of 16x2 LCD 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F CA CB CC CD CE CF

LCD INTERFACING TO 8051

STEPPER MOTOR INTERFACING A Stepper motor is a widely used device that translates electrical pulses into mechanical movement. In applications such as disk drives, dot matrix printers & robotics, the stepper motor is used for position control Stepper motors commonly have a permanent magnet ‘rotor’( also called shaft) surrounded by a ‘stator’.

Stator Windings Configuration

Normal 4 Step Sequence Wave Drive 4 step sequence Driving Stepper motor Normal 4 Step Sequence Wave Drive 4 step sequence CLOCKWISE STEP WINDING A WINDING B WINDING C WINDING D COUNTER CLOCKWISE 1 2 3 4 CLOCKWISE STEP WINDING A WINDING B WINDING C WINDING D COUNTER CLOCKWISE 1 2 3 4

Half step 8-step sequence Step Sequence Driving Stepper motor Half step 8-step sequence Step Sequence CLOCKWISE STEP WINDING A WINDING B WINDING C D COUNTER CLOCKWISE 1 2 3 4 5 6 7 8

Interfacing Circuit

ULN2803

Stepper Motor Program Assuming two stepper motors are interfaced to 8051 with ULN2803 drivers. Program for normal 4-step sequence ( clock wise ) ORG 0H BACK: MOV A,#0CCH MOV P1,A ACALL DELAY DELAY: MOV A,#66H MOV R0,#0FFH MOV P1,A LOOP2: MOV R1,#80H ACALL DELAY LOOP1: DJNZ R1,LOOP1 MOV A,#33H DJNZ R0,LOOP2 MOV P1,A RET ACALL DELAY MOV A,#99H SJMP BACK END

Stepper Motor Program Assuming two stepper motors are interfaced to 8051 with ULN2803 drivers. Program for wave drive 4-step sequence ( clock wise ) ORG 0H BACK: MOV A,#88H MOV P1,A ACALL DELAY DELAY: MOV A,#44H MOV R0,#0FFH MOV P1,A LOOP2: MOV R1,#80H ACALL DELAY LOOP1: DJNZ R1,LOOP1 MOV A,#22H DJNZ R0,LOOP2 MOV P1,A RET ACALL DELAY MOV A,#11H SJMP BACK END

Stepper Motor Program Assuming two stepper motors are interfaced to 8051 with ULN2803 drivers. Program for half step 8-step sequence ( clock wise ) ORG 0H BACK: MOV A,#88H MOV A,#22H MOV P1,A MOV P1,A ACALL DELAY ACALL DELAY DELAY: MOV A,#0CCH MOV A,#33H MOV R0,#0FFH MOV P1,A MOV P1,A LOOP2: MOV R1,#80H ACALL DELAY ACALL DELAY LOOP1: DJNZ R1,LOOP1 MOV A,#44H MOV A,#11H DJNZ R0,LOOP2 MOV P1,A MOV P1,A RET ACALL DELAY ACALL DELAY MOV A,#66H MOV A,#99H SJMP BACK END

KEYBOARD INTERFACING

Keyboard Program

ADC(0804) INTERFACING ADCs( Analog-to-Digital Converters) are among the most widely used devices for data acquisition. A Physical quantity, like temperature, pressure, humidity, and velocity, etc., is converted to electrical ( Voltage , current) signals using a device called a transducer or sensor. We need ADCs to translate the analog signals to digital numbers, so that the microprocessor/microcontroller can read the data for further implement.

ADC 0804

Important Points on ADC 0804 Vcc It works with +5 volts and has a resolution of 8 bits. Conversion time is another major factor in judging an ADC. a. Conversion time is defined as the time it takes the ADC to convert the analog input to a digital (Binary) number. b. In ADC804 conversion time varies depending on the clocking signals applied to CLK R and CLK IN pins, but it cannot be faster than 110 μs

3. CLK IN and CLK R a. CLK IN is an input pin connected to an external clock source b. To use the internal clock generator (also called self- clocking), CLK IN and CLK R pins are connected to a capacitor and a resistor, and the clock frequency is determined by Typical values are R = 10K ohms and C = 150 pF. We get f = 606 kHz and the conversion time is 110 μs.

4. VRef/2: It is used for the reference voltage If this pin is open (not connected), the analog input voltage is in the range of 0 to 5 volts (the same as the Vcc pin) If the analog input range needs to be 0 to 4 volts, VRef/2 is connected to 2 volts

5. Analog ground and digital ground Analog ground is connected to the ground of the analog Vin. Digital ground is connected to the ground of the Vcc pin. 6. CS( Chip Select) Chip select is an active low input used to activate the ADC0804 chip. 7. RD(Read) This is an input signal and is active low. The ADC converts the analog input to its binary equivalent and holds it in an internal register. RD is used to get the converted data out of the ADC0804 chip. When CS=0, if a high-to-low pulse is applied to the RD pin, the 8-bit digital output can be read from D0-D7. The RD pin is also referred to as Output Enable(OE).

8. WR( Write , a better name might be “start of Conversion”) This is an active low input used to inform the ADC0804 to start the conversion process. If CS=0, when WR makes a low-to-high transition, the ADC0804 starts converting the analog input value of Vin to an 8-bit digital number 9. INTR( Interrupt, a better name might be “End of Conversion”) This is an output pin and is active low. It is normally high pin and when the conversion is completed, it goes low to signal the CPU that the converted data is ready to be picked up. After INTR goes low, we make CS=0 and send a high- to- low pulse to the RD pin to get the next analog data to be converted.

 

Timing diagram of ADC 0804

Interfacing circuit of ADC0804

Program for ADC0804 RD BIT P2.5 WR BIT P2.6 INTR BIT P2.7 MYDATA EQU P1 MOV P1,#0FFH SETB INTR CLR WR SETB WR HERE: JB INTR, HERE CLR RD MOV A,MYDATA ACALL CONVERSION ACALL DATA_DISPLAY SETB RD SJMP BACK

DAC(0808) INTERFACING

Interfacing Circuit of DAC 0808

 

Specifications related to DAC Resolution: It can be defined as a smallest change in the output corresponding to an input change by one LSB. Accuracy: This is the measure of the difference between the actual output voltage & the expected output voltage. Full scale output voltage: This is the output voltage when binary input has the highest value. For ex: 8-bit 5V DAC have max voltage 5V-19.5mv= 4.9805V.

Generating Staircase waveform ORG 0H START: CLR A AGAIN: MOV P1,A ;Send data to DAC INC A ;count from 0h to FFh ACALL DELAY ;Let DAC recover CJNE A,#0FFH,GO SJMP START GO: SJMP AGAIN DELAY: MOV R0,#0FFH LOOP: DJNZ R0,LOOP RET END

Generating Triangular waveform ORG 0H START0to1: CLR A AGAIN1: MOV P1,A ;Send data to DAC INC A ;count from 0h to FFh ACALL DELAY ;Let DAC recover CJNE A,#0FFH,GO1 SJMP START1to0 GO1: SJMP AGAIN1 START1to0: MOV P1,A DEC A ACALL DELAY CJNE A,#00H,GO2 DELAY: MOV R0,#0FFH SJMP START0to1 LOOP: DJNZ R0,LOOP GO2: SJMP START1to0 RET END

Generating Sine waveform To generate a sine wave , we first need a table whose values represent the magnitude of the sine of angles between 00 & 3600 The values for the sine function vary from -1.0 to +1.0 for 00 & 3600 angles. Therefore, the table values are integer numbers representing the voltage magnitude for the sine of theta (θ). To generate sine wave we assume the full scale voltage of 10V for DAC output. Full scale output of the DAC is achieved when all the data inputs of the DAC are high. Therefore, to achieve the full scale 10V output, we use the following equation. VOut = 5V + ( 5 X Sin θ)

Example

Program ORG 0H MOV DPTR,#TABLE MOV R2,#COUNT BACK: CLR A MOVC A,@A+DPTR MOV P1,A INC DPTR DJNZ R2,BACK SJMP AGAIN ORG 0300H TABLE: DB 128,192,238,255,238,192,128,64,17,0,17,64,128

Representation of Sine waveform Volts 10 9 8 7 6 5 4 3 2 1 0 30 60 90 120 150 180 210 240 270 300 330 360 Degrees