Presentation on theme: "UNIT-IV 8255 PPI Various Modes Of Operation Interfacing To 8086."— Presentation transcript:
1 UNIT-IV 8255 PPI Various Modes Of Operation Interfacing To 8086. Interfacing Keyboard, DisplaysStepper MotorD/A And A/D Converter Interfacing.
2 8255Programmable Peripheral Interface(PPI) For most of the applications 8086 needs parallel input ,output data to/from the peripherals.8255 is a device used to interface different real time peripherals to the microprocessors which can be initialized for different modes operations like simple I/O, Strobed I/O and handshaking I/O.It has three 8-bit parallel ports :port A, port B, port C
4 8255 has three operation modes: mode 0, mode 1, and mode 2 Fig 4.3 Control Word Register Bit Format of 8255 for I/O mode and BSR mode
5 Fig 4.4 Input and Output control signals of 8255 in mode1 Programming 8255Mode 0:Ports A, B, and C can be individually programmed as input or output portsPort C is divided into two 4-bit ports which are independent from each otherMode 1:Ports A and B are programmed as input or output portsPort C is used for handshakingPA[7:0]STBAIBFAINTRAPC3PC5PC4PB[7:0]STBBIBFBINTRBPC0PC1PC2PC6, 78255OBFAACKAPC6PC7OBFBACKBPC4, 5Fig 4.4 Input and Output control signals of 8255 in mode1
7 Fig 4.5 Input and Output control signals of 8255 in mode1
8 Fig 4.6 Input and Output control signals of 8255 in mode2 Programming 8255Mode 2:Port A is programmed to be bi-directionalPort C is for handshakingPort B can be either input or output in mode 0 or mode 1PA[7:0]OBFAACKAINTRAPC4PC6PC7STBAIBFAPC0PC3PC58255PB[7:0]In OutMode 0STBB OBFBIBFB ACKBINTRB INTRBMode 1Fig 4.6 Input and Output control signals of 8255 in mode2
9 Fig 4.7 Input and Output control signals of 8255 in mode2
10 Fig 4.8 Interfacing of 8255 to Keyboard for input in mode1 Example: Mode 1 InputBIT5 EQU 20HPORTC EQU 22HPORTA EQU 20HREAD PROC NEARRead:IN AL, PORTC ; read portcTEST AL, BIT5 ;test IBFJZ Read ;if IBF=0IN AL, PORTA ;Read DataREAD ENDPkeyboard8255PA0PA7STBPC4DAVFig 4.8 Interfacing of 8255 to Keyboard for input in mode1
11 Fig 4.9 Interfacing of 8255 to Printer for output in mode1 Example: Mode 1 outputPrinter8255PB0PB7ACKPC2ACKPC4DSFig 4.9 Interfacing of 8255 to Printer for output in mode1
12 Example: Mode 1 output BIT1 EQU 2 PORTC EQU 62H PORTB EQU 61H CMD EQU 63HPRINT PROC NEAR; check printer ready?IN AL, PORTC ;get OBFTEST AL, BIT1 ;test OBFJZ PRINT ;if OBF=0 buffer is full;send character to printerMOV AL, AH ;get dataOUT PORTB, AL ;print data; send data strobe to printerMOV AL, 8 ;clear DSOUT CMD, ALMOV AL, 9 ;clear DS;rising the data at the positive edge of DSRETPRINT ENDP
13 Fig 4.1 Interfacing of 8255 PPI to 8086 Data bus8086D[7:0]A0A1RDWRRESETCSControl portPA[7:0]PB[7:0]PC[7:0]A7A6A5A4A3A2IO/MA1 A0PortPAPBPCControlFig 4.1 Interfacing of 8255 PPI to 8086
14 Fig 4.10 Interfacing of 8255 to 4x4 matrix Keyboard in mode1 Keyboard exampleFig 4.10 Interfacing of 8255 to 4x4 matrix Keyboard in mode1
15 Fig 4.11 Flow chart of a keyboard scanning procedure Keyboard exampleFig 4.11 Flow chart of a keyboard scanning procedure
19 ADC InterfacingThe time taken by the ADC from the active edge of SOC pulse till the active edge of EOC signal is called as the conversion delay of the ADC.General algorithm for ADC interfacing contains the following stepsEnsure the stability of analog input, applied to the ADCIssue start of conversion SOC pulse to ADCRead end of conversion EOC signal to mark the end of conversion processRead digital data output of the ADC as equivalent digital output.
20 ADC 0808/0809The analog to digital converter chips 0808 and are 8-bit CMOS, successive approximation converters. It is fastest technique.The conversion delay is 100 µs at a clock frequency of 640 kHz, which is quite low as compared to other converters.Block Diagram of ADC 0808/0809This converter internally has a 3:8 analog multiplexer, so that at a time 8 different analog inputs can be connected to the chips.Out of these 8 inputs only one can be selected for conversion by using 3 address lines A,B,C.The CPU may drive these lines using output port lines in case of multichannel applications.
22 Table 4.1 analog input selection These are unipolar Analog to Digital (A to D) converters, they are able to convert only positive analog input voltages to their digital equivalents. This chips do not contain any internal sample & hold circuit.
23 Interfacing between ADC to Microprocessor Problem:-Interface ADC 0808 with 8086 using 8255 ports. Use Port A of 8255 for transferring digital data output of ADC to the CPU & Port C for control signals. Assume that an analog input is present at I/P2 of the ADC and a clock input of suitable frequency is available for ADC. Draw the schematic & timing diagram of different signals of ADC0808.
24 Solution:-The analog input I/P2 is used & therefore address pins A,B,C should be 0,1,0 respectively to select I/P2.The OE (Out put latch Enable) & ALE pins are already kept at +5v to select the ADC and enable the outputs.Port C upper acts as the input port to receive the EOC signal while Port C lower acts as the output port to send SOC to ADC.Port A acts as a 8-bit input data port to receive the digital data output from the ADC.
25 8255 Control Word: D7 D6 D5 D4 D3 D2 D1 D0 1 0 0 1 1 0 0 0 = 98H Program:MOV AL,98H ; Initialize 8255, send AL to control word (CWR)OUT CWR, ALMOV AL, 02H ;Select I/P2 as analog I/POUT Port B, AL ;Port B as outputMOV AL, 00H ; Give start of conversion pulse to the ADCOUT Port C, ALMOV AL, 01HMOV AL, 00HOUT Port C, ALWAIT: IN AL, Port C ; check for EOC by reading Port C upper & rotatingRCL ; through carry.JNC WAITIN AL, Port A ; if EOC, read digital equivalent in ACHLT ; stop.
26 Fig 4.16 Interfacing of ADC 0808 to 8086 through 8255
27 Interfacing D/A Converters The Digital to Analog Converters (DAC) convert binary numbers into their analog equivalent voltages.The DAC find applications in areas likeDigitally controlled gainsMotor speed controlsProgrammable gain amplifiers etc.AD Bit Multiplying DAC:--Intersil’s AD 7523 is a 16 pin DIP, multiplying digital to analog converter, containing R-2R ladder (R=10K) for digital to analog conversion.
28 Power supply +5v to +15vVref -> -10v to +10vThe maximum analog output voltage will be +10vA Zener is connected between OUT1 & OUT2 to save the DAC from negative transients.An operational amplifier is used as a current – to – voltage converter at the output of AD 7523.An external feedback resister acts to control the gain.
29 Interfacing of AD 7523 with 8086 Problem:-- Interface DAC AD7523 with the 8086 running at 8MHz & write ALP to generate a saw tooth waveform of period 1ms with Vmax 5v.Solution:--Code segmentAssume cs:codeStart: MOV AL, 80HOUT CWR, ALAGAIN: MOV AL, 00HBACK: OUT Port A, ALINC ALCMP AL, 0F2HJB BACKJMP AGAINCode endsEnd Start
31 Fig 4.18 Interfacing of AD7523 to 8086 through 8255
32 Display interfaceInterface an 8255 with 8086 at 80h as an I/O address of port-A. interface five 7 segment displays with the write a sequence of instructions to display 1,2,3,4 and 5 over the five displays continuously as per their positions starting with 1 at the least significant position. CWR address is 86h.Number to be displayedPA7dpPA6aPA5bPA4cPA3dPA2ePA1fPA0gCode1CF2923864CC5A4All these codes are stored in a look up table starting at 2000:0001.
33 Fig 4.19 Interfacing multiplexed 7-segment display to 8086 through 8255
34 ALP for display interface again: mov cl,05h ;count for displaysmov bx,2000h ;initialize the data segment formov ds,bx ; look-up tablemov ch,01h ;1st no. to be displayedmov al,80hout 86h,al ;load control word in the CWRmov dl,01h ;enable code for least significant 7-seg displaynxtdgt: mov bx,0000h ;set pointer to look-up tablemov al,ch ;store number to be displayxlat ;find code from table
35 out 80h,almov al,dlout 82h,al ;enable the displayrol dl ;go for next digit displayinc chdec cl ;decrement counterjnz nxtdgt ;go for next digit displayjmp again
36 Stepper Motor Interfacing A stepper motor is a device used to obtain an accurate position control of rotating shafts.It employs rotation of its shaft in terms of steps, rather than continuous rotation as in case of AC or DC motors.In dot-matrix printer one small stepper motor which is used to advance the paper to the next line position & another small stepper motor which is used to move the print head to the next character position.In floppy disk stepper motor is used to position the read/write head over the desired track.To rotate the shaft of the stepper motor, a sequence of pulses is needed to be applied to the windings of the stepper motor, in a proper sequence.The no. of pulses required for one complete rotation of the shaft of the stepper motor are equal to its number of internal teeth on its rotor.
37 The stator teeth the rotor teeth lock with each other to fix a position of the shaft . With a pulse applied to the winding input, the rotor rotates by one teeth position or an angle x. The angle x may be calculated as:x = / no. of rotor teethThe stepper motors have been designed to work with digital circuits. Binary level pulses of 0-5v are required at its winding inputs to obtain the rotation of shafts.The sequence of pulses can be decided, depending upon the required motion of the shaft.The count for rotating the shaft of the stepper motor through a specified angle may be calculated from the no. of rotor teethC = no. of rotor teeth / 3600 * θ0
38 MotionStepABCDClockwise12345AnticlockwiseTable 4.2 Excitation sequence for clockwise and anticlockwise rotation of a stepper motor
39 ProblemDesign a stepper motor controller and write an ALP to rotate shaft of a 4-phase stepper motor:In clockwise 5 rotationsIn anticlockwise 5 rotations.The 8255 port A address is 0740h. The stepper motor has 200 rotor teeth.The port A bit PA0 drives winding Wa, PA1 drives winding Wb and so on.The stepper motor has an internal delay of 10msec. Assume that the routine for this delay is already available.
40 Solution:ALP:Assume cs:CodeCode segmentStart: MOV AL, 80HOUT CWR, ALMOV AL, 88H; Bit patternMOV CX, 1000Again1: OUT Port A, ALCALL DELAYROL AL, 01DEC CXJNZ Again1MOV AL, 88H
41 Again2: OUT Port A, AL CALL DELAY ROR AL, 01 DEC CX JNZ Again2 MOV AH, 4CH INT 21H Code ends End start