Programable I/O expanding decoder using 8255 PPI part-1

8255 I/O DECODER


PREFACE

            As you can see from the article LPT port expander, this PPI-8255 is a general purpose I/O programmable function. But usually this IC are tired to the computer bus directly. Return to this idea, here I will show you that the card can be used to dual function purpose. Beside for the expander port, it can be used for I/O functional directly. So we can used the card both for the expander experiment or for direct connection to the computer bus experiment. Why do you need this I/O directly connection for? Many article on the net usually used this method for I/O interfacing. So by doing this, we can take 2 benefits. First, we can used many useful routines (usually with the tested ones) or directly used the softwares (?) or routines; secondly, we can used many hardware design by someone else (compatibility type). At most we can replace the I/O parts. Happy programming and happy surfing on the net.

DETAILS

            To directly connected a hardware to computer bus, we need an I/O decoding. Here I don't explain anymore, please refer to the topic of decoding technique at the other page. There are 2 type of decoding technique, ie: partial decoding, when we want to reduce the components using or full decoding. I prefer the last one. The decoder circuit must be preserve all of the possible unused I/O ports, easy to select the address, and not ambiguous for the future compatibility design. I used a comparator 74LS682 type and a dip switch for this purpose. Besides that the lines need buffers because the card may put far away from the PC. The complete circuit diagram shown at fig-1.
            One thing must remember that, when doing re-boot-ing the PC, the expander card must be connected to this decoder card. So the PPI can be reset. If not, the PPI can not be initialized. To anticipate this purpose, we can add a push on switch between +Vcc and reset pin of PPI. So you can connected the expander card at any time, when ever you want and without re-boot-ing the PC. Initialized perform when the software being execute. Some connection also must be changed to make the circuit work with this decoder card. The explanation will be clearly later.

click the image for enlarge

                                          Fig-1. I/O decoding for PPI-8255 circuit diagram.

SOFTWARE

            Nothing to say about this card programming. It is quiet easy. You can access the port by accessing directly to 4 contiguous port location, eg: if the decoder set to port 220 hex, so port-A = 220 H, port-B = 221 H, port-C = 222 H, port-CW = 223 H.
            First, initialize it by sending the control word data to port-CW (control word data contain mode setting for each port). Refer to PPI-8255 data book for more detailed explanation. Then each port can be accessing directly. Here are a sample of initialize routine for mode-0 for any language.
 
In PASCAL routine : 
CONST
     Base_Port = $220;
     Port_A = Base_Port;
     Port_B = Base_Port+1;
     Port_C = Base_Port+2;
     Port_CW = Base_Port+3;
     CW_Data = $82;       { Port-A = output, Port-B = input, port-C = output }

PROCEDURE Initialize_Port;
BEGIN
     PORT[Port_CW] := CW_Data;       { Send Control Word }
END;
PROCEDURE Read_Write_Port_A(Datanya : BYTE);
BEGIN
     ...
     PORT[Port_A] := Datanya;  { Send a Byte }
     ...
END;

FUNCTION Read_Port_B : BYTE;
BEGIN
     ...
     Read_Port_B := PORT[Port_B];   { Receive a Byte }
     ...
END;
PROCEDURE Write_Port_C(Datanya : BYTE);
BEGIN
     ...
     PORT[Port_C] := Datanya;  { Send a Byte }
     ...
END;

 
In ASSEMBLY routine : 
Base_Port EQU 220 H
Port_A    EQU Base_Port
Port_B    EQU Base_Port+1
Port_C    EQU Base_Port+2
Port_CW   EQU Base_Port+3
CW_Data   EQU 82 H           ;Port-A = output, Port-B = input, Port-C = output
Dummy     EQU 5A H

Initialize_Port PROC NEAR
          MOV  DX,Port_CW
          MOV  AL,CW_Data    ;Send Control Word
          OUT  DX,AL
          RET
Initialize_Port ENDP
Write_Port_A PROC NEAR
          ...
          MOV  DX,Port_A
          MOV  AL,Dummy      ;Send a Byte
          OUT  DX,AL
          ...
          RET
Write_Port_A ENDP
Read_Port_B PROC NEAR
          ...
          MOV  DX,Port_B
          IN   AL,DX
          MOV  Dummy,AL      ;Receive a Byte
          ...
          RET
Read_Port_B ENDP
Write_Port_C PROC NEAR
          ...
          MOV  DX,Port_C
          MOV  AL,Dummy      ;Send a Byte
          OUT  DX,AL
          ...
          RET
Write_Port_C ENDP

 
In BASIC routine : 
Base_Port = &H220
Port_A = Base_Port
Port_B = Base_Port+1
Port_C = Base_Port+2
Port_CW = Base_Port+3
CW_Data = &H82     ;REM ----- Port-A = output, Port-B = input, Port-C = output
Dummy = &H5A
PROC Initialize_Port
     OUT Port_CW,CW_Data     :REM ----- Send Control Word     
END PROC
PROC Write_Port_A
     ...
     OUT Port_A,Dummy        :REM ----- Send a Byte
     ...
END PROC
PROC Read_Port_B
     ...
     INP Dummy,Port_B        :REM ----- Receive a Byte
     ...
END PROC
PROC Write_Port_C
     ...
     OUT Port_C,Dummy        :REM ----- Send a Byte
     ...
END PROC

 
In C routine : 
#define Base_Port 0x220
int Port_A = Base_Port;
int Port_B = Base_Port+1;
int Port_C = Base_Port+2;
int Port_CW = Base_Port+3;
unsigned CW_Data = 0x82;/* Port-A = output, Port-B = input, Port-C = output */
unsigned Dummy = 0x5A;
               
void Initialize_Port()
{
     ...
     outp(Port_CW) = Dummy;  /* Send Control Word */
     ...
}
void Write_Port_A()
{
     ...
     outp(Port_A) = Dummy;   /* Send a Byte */
     ...
}
void Read_Port_B()
{
      ...
     Dummy = inp(Port_B);    /* Receive a Byte */
     ...
}
void Write_Port_C()
{
     ...
     outp(Port_C) = Dummy;   /* Send a Byte */
     ...
}
            A sample in assembly program show the demo for the possible combination of mode-0. If you already have built the project of 36-bits led display driver, you can put it to the output port-A through port-C. A nice display. I plan to write the sample program for mode-2. May be I could published it later.
At last, I found a good software to demonstrate this mode programming capabilities. This program was made by someone else and could shows the I/O state for each mode setting, as input port or output port. A good example software.

No comments:

Post a Comment

Labels

PROJECTS 8086 PIN CONFIGURATION 80X86 PROCESSORS TRANSDUCERS 8086 – ARCHITECTURE Hall-Effect Transducers INTEL 8085 OPTICAL MATERIALS BIPOLAR TRANSISTORS INTEL 8255 Optoelectronic Devices Thermistors thevenin's theorem MAXIMUM MODE CONFIGURATION OF 8086 SYSTEM ASSEMBLY LANGUAGE PROGRAMME OF 80X86 PROCESSORS POWER PLANT ENGINEERING PRIME MOVERS 8279 with 8085 MINIMUM MODE CONFIGURATION OF 8086 SYSTEM MISCELLANEOUS DEVICES MODERN ENGINEERING MATERIALS 8085 Processor- Q and A-1 BASIC CONCEPTS OF FLUID MECHANICS OSCILLATORS 8085 Processor- Q and A-2 Features of 8086 PUMPS AND TURBINES 8031/8051 MICROCONTROLLER Chemfet Transducers DIODES FIRST LAW OF THERMODYNAMICS METHOD OF STATEMENTS 8279 with 8086 HIGH VOLTAGE ENGINEERING OVERVOLATGES AND INSULATION COORDINATION Thermocouples 8251A to 8086 ARCHITECTURE OF 8031/8051 Angle-Beam Transducers DATA TRANSFER INSTRUCTIONS IN 8051/8031 INSTRUCTION SET FOR 8051/8031 INTEL 8279 KEYBOARD AND DISPLAY INTERFACES USING 8279 LOGICAL INSTRUCTIONS FOR 8051/8031 Photonic Transducers TECHNOLOGICAL TIPS THREE POINT STARTER 8257 with 8085 ARITHMETIC INSTRUCTIONS IN 8051/8031 LIGHTNING PHENOMENA Photoelectric Detectors Physical Strain Gage Transducers 8259 PROCESSOR APPLICATIONS OF HALL EFFECT BRANCHING INSTRUCTIONS FOR 8051/8031 CPU OF 8031/8051 Capacitive Transducers DECODER Electromagnetic Transducer Hall voltage INTEL 8051 MICROCONTROLLER INTEL 8251A Insulation Resistance Test PINS AND SIGNALS OF 8031/8051 Physical Transducers Resistive Transducer STARTERS Thermocouple Vacuum Gages USART-INTEL 8251A APPLICATIONs OF 8085 MICROPROCESSOR CAPACITANCE Data Transfer Instructions In 8086 Processors EARTH FAULT RELAY ELECTRIC MOTORS ELECTRICAL AND ELECTRONIC INSTRUMENTS ELECTRICAL BREAKDOWN IN GASES FIELD EFFECT TRANSISTOR (FET) INTEL 8257 IONIZATION AND DECAY PROCESSES Inductive Transducers Microprocessor and Microcontroller OVER CURRENT RELAY OVER CURRENT RELAY TESTING METHODS PhotoConductive Detectors PhotoVoltaic Detectors Registers Of 8051/8031 Microcontroller Testing Methods ADC INTERFACE AMPLIFIERS APPLICATIONS OF 8259 EARTH ELECTRODE RESISTANCE MEASUREMENT TESTING METHODS EARTH FAULT RELAY TESTING METHODS Electricity Ferrodynamic Wattmeter Fiber-Optic Transducers IC TESTER IC TESTER part-2 INTERRUPTS Intravascular imaging transducer LIGHTNING ARRESTERS MEASUREMENT SYSTEM Mechanical imaging transducers Mesh Current-2 Millman's Theorem NEGATIVE FEEDBACK Norton's Polarity Test Potentiometric transducers Ratio Test SERIAL DATA COMMUNICATION SFR OF 8051/8031 SOLIDS AND LIQUIDS Speed Control System 8085 Stepper Motor Control System Winding Resistance Test 20 MVA 6-digits 6-digits 7-segment LEDs 7-segment A-to-D A/D ADC ADVANTAGES OF CORONA ALTERNATOR BY POTIER & ASA METHOD ANALOG TO DIGITAL CONVERTER AUXILIARY TRANSFORMER AUXILIARY TRANSFORMER TESTING AUXILIARY TRANSFORMER TESTING METHODS Analog Devices A–D BERNOULLI’S PRINCIPLE BUS BAR BUS BAR TESTING Basic measuring circuits Bernoulli's Equation Bit Manipulation Instruction Buchholz relay test CORONA POWER LOSS CURRENT TRANSFORMER CURRENT TRANSFORMER TESTING Contact resistance test Current to voltage converter DAC INTERFACE DESCRIBE MULTIPLY-EXCITED Digital Storage Oscilloscope Display Driver Circuit E PROMER ELPLUS NT-111 EPROM AND STATIC RAM EXCITED MAGNETIC FIELD Electrical Machines II- Exp NO.1 Energy Meters FACTORS AFFECTING CORONA FLIP FLOPS Fluid Dynamics and Bernoulli's Equation Fluorescence Chemical Transducers Foil Strain Gages HALL EFFECT HIGH VOLTAGE ENGG HV test HYSTERESIS MOTOR Hall co-efficient Hall voltage and Hall Co-efficient High Voltage Insulator Coating Hot-wire anemometer How to Read a Capacitor? IC TESTER part-1 INSTRUMENT TRANSFORMERS Importance of Hall Effect Insulation resistance check Insulator Coating Knee point Test LEDs LEDs Display Driver LEDs Display Driver Circuit LM35 LOGIC CONTROLLER LPT LPT PORT LPT PORT EXPANDER LPT PORT LPT PORT EXTENDER Life Gone? MAGNETIC FIELD MAGNETIC FIELD SYSTEMS METHOD OF STATEMENT FOR TRANSFORMER STABILITY TEST METHODS OF REDUCING CORONA EFFECT MULTIPLY-EXCITED MULTIPLY-EXCITED MAGNETIC FIELD SYSTEMS Mesh Current Mesh Current-1 Moving Iron Instruments Multiplexing Network Theorems Node Voltage Method On-No Load And On Load Condition PLC PORT EXTENDER POTIER & ASA METHOD POWER TRANSFORMER POWER TRANSFORMER TESTING POWER TRANSFORMER TESTING METHODS PROGRAMMABLE LOGIC PROGRAMMABLE LOGIC CONTROLLER Parallel Port EXPANDER Paschen's law Piezoelectric Wave-Propagation Transducers Potential Transformer RADIO INTERFERENCE RECTIFIERS REGULATION OF ALTERNATOR REGULATION OF THREE PHASE ALTERNATOR Read a Capacitor SINGLY-EXCITED SOLIDS AND LIQUIDS Classical gas laws Secondary effects Semiconductor strain gages Speaker Driver Strain Gages Streamer theory Superposition Superposition theorem Swinburne’s Test TMOD TRANSFORMER TESTING METHODS Tape Recorder Three-Phase Wattmeter Transformer Tap Changer Transformer Testing Vector group test Virus Activity Voltage Insulator Coating Voltage To Frequency Converter Voltage to current converter What is analog-to-digital conversion Windows work for Nokia capacitor labels excitation current test magnetic balance voltage to frequency converter wiki electronic frequency converter testing voltage with a multimeter 50 hz voltages voltmeter

Search More Posts

Followers