Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Overflow Flag The overflow flag is bit 2 of the PSW.

This flag is set after an addition or subtraction operation if the result in the accumulator is outside the signed 8-bit range (128 to 127). 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 the result 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 the fact that the correct answer (138) is too big to be represented by an 8-bit signed number. Therefore, the OV flag is set to alert the program that the result is out of range.

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, we connect 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 by itself gives out the correspondent 7 segment codes to the LED. Here we explain using lookup table. Click 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 <previous> setup where we entered the patterns manually to display the desired character. Here in 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 7447 and the Output 8 pins of 7447 to the 8 legs of the LED as shown in the figure. Te circuit diagrams 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 the Microcontroller. The 7447 converts the four input bits (BCD) to their corresponding 7-segment codes. The outputs of the 7447 are connected to the 7-segment display.

Circuit diagram for interfacing Common Anode 7-Segment Display

Circuit diagram for Common Cathode 7-Segment Display Program:

EA The 8051 family members, such as the 8751/52, 89C51/52, or DS89C4xO, all come with on-chip ROM to store programs. In such cases, the EA pin is connected to Vcc. For family members such as the 8031 and 8032 in which there is no on-chip ROM. code is stored on an external ROM and is fetched by the 8031/32. Therefore, for the 8031 the EA pin must be connected to GND to indicate 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 Vcc 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 programs stored in ROM memory located outside the 8031. In 8051 chips with on-chip ROM, such as the 8751/52, 89C51/52, or DS89C4xO, EA is connected to Vcc, as we will see in the next section.

The pins discussed so far must be connected no matter which family member is used. The next two 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 in which 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. ALE ALE (address latch enable) is an output pin and is active high. When connecting an 8031 to external memory, port 0 provides both address and data. In other words, the 8031 multiplexes address and data through port 0 to save pins. The ALE pin is used for demultiplexing the address and 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 use 8 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 the materials in Chapter 4.

You might also like