overflow flag

Upload: malhiavtarsingh

Post on 14-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 Overflow Flag

    1/3

    There 2 methods of interfacing LED with the Microcontroller Intel 8051/8951.

    1. Using lookup table. This uses 7 output pins of microcontroller 2. Using 7447 decoder. This method uses 4 output pins of microcontroller

    The difference between the two main methods is simple and clear. In both the cases,microcontroller communicates with external world through its ports. But, in the 1st case, weconnect all the 8 pins of the port directly to the LED and control the voltage through the ports

    manually to display the desired number. But, in the second case, we send the BCD of the number that we wanted to display to a middleware IC 7447, the BCD to LED code converter, which byitself gives out the correspondent 7 segment codes to the LED.

    Here we explain using lookup table. Cl ick here for the method using 7447 decoder

    Using 7447 decoder:

    The IC7447 is a BCD to 7-segment pattern converter. This setup is the advanced form of the setup where we entered the patterns manually to display the desired character. Herein this case, the IC7447 takes the Binary Coded Decimal (BCD) as the input and outputs the

    relevant 7 segment code. We connect first four pins of the microcontroller Port 2 to the 7447and the Output 8 pins of 7447 to the 8 legs of the LED as shown in the figure. Te circuitdiagrams are shown below, the first figure is interfacing the CA LED where as the second is of CC LED. The number required to display is sent as the lower nibble of the Port 2 of theMicrocontroller. The 7447 converts the four input bits (BCD) to their corresponding 7-segmentcodes. The outputs of the 7447 are connected to the 7-segment display.

    Overflow FlagThe overflow flag is bit 2 of the PSW. This flag is set after an addition or subtractionoperation if the result in the accumulator is outside the signed 8-bit range ( 128 t127). In other words, if the addition or subtraction of two numbers results in a number less than 128 or greater than 127, the OV flag is set.

    When signed numbers are added or subtracted, software can check this flag to see if theresult is in the range 128 to 127. For example: 115 + 23 = 138 (73H + 17H = 8AH). If these numbers are being treated as signed numbers then 8AH is (as a signed number)118 in decimal. Obviously, 115 + 23 is not equal to 118. The problem lies with thefact that the correct answer (138) is too big to be represented by an 8-bit signednumber. Therefore, the OV flag is set to alert the program that the result is out of range.

    http://electrofriends.com/articles/electronics/microcontroller-electronics-articles/8051-8951/interfacing-7-segment-display-with-microcontroller-using-lookup-table/http://electrofriends.com/articles/electronics/microcontroller-electronics-articles/8051-8951/interfacing-7-segment-display-with-microcontroller-using-lookup-table/http://electrofriends.com/articles/electronics/microcontroller-electronics-articles/8051-8951/interfacing-7-segment-display-with-microcontroller-using-lookup-table/
  • 7/30/2019 Overflow Flag

    2/3

    Circuit diagram for interfacing Common Anode 7-Segment Display

    Circuit diagram for Common Cathode 7-Segment Display

    Program:

  • 7/30/2019 Overflow Flag

    3/3

    EA

    The 8051 family members, such as the 8751/52, 89C51/52, or DS89C4xO, all come with on-chipROM to store programs. In such cases, the EA pin is connected to V cc. For family members suchas the 8031 and 8032 in which there is no on-chip ROM. code is stored on an external ROM andis fetched by the 8031/32. Therefore, for the 8031 the EA pin must be connected to GND toindicate that the code is stored externally. EA . which stands for external access, is pin number 31 in the DIP packages. It is an input pin and must be connected to either V cc or GND. In other words, it cannot be left unconnected.

    In Chapter 14, we will show how the 8031 uses this pin along with PSEN to access programsstored in ROM memory located outside the 8031. In 8051 chips with on-chip ROM, such as the8751/52, 89C51/52, or DS89C4xO, EA is connected to V cc, as we will see in the next section.

    The pins discussed so far must be connected no matter which family member is used. The nexttwo pins are used mainly in 8031-based systems and are discussed in more detail in Chapter 14.The following is a brief description of each.PSEN

    This is an output pin. PSEN stands for program store enable. In an 8031-based system inwhich an external ROM holds the program code, this pin is connected to the OE pin of the ROM.See Chapter 14 to see how this is used.A L E

    ALE (address latch enable) is an output pin and is active high. When connecting an 8031 toexternal memory, port 0 provides both address and data. In other words, the 8031 multiplexesaddress and data through port 0 to save pins. The ALE pin is used for demultiplexing the addressand data by connecting to the G pin of the 74LS373 chip. This is discussed in detail in Chapter 14.Ports 0, 1, 2 and 3

    As shown in Figure 8-1 (and discussed in Chapter 4), the four ports PO, PI, P2, and P3 each use8 pins, making them 8-bit ports. All the ports upon RESET are configured as input, since PO P3 have value FFH on them. The following is a summary of features of PO P3 based on thematerials in Chapter 4.