0% found this document useful (0 votes)
10 views5 pages

CY, The Carry Flag: PSW (Program Status Word) Register

The document provides an overview of the 8051 microcontroller, detailing the functions of the Program Status Word (PSW) register, I/O ports, and instructions like JUMP and CALL. It explains the roles of various flags in the PSW, the characteristics of each I/O port, and the differences between MOV and MOVX instructions. Additionally, it describes the pin diagram and functions of the 8051, emphasizing its use in interfacing with external devices and programming.

Uploaded by

veenakeeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

CY, The Carry Flag: PSW (Program Status Word) Register

The document provides an overview of the 8051 microcontroller, detailing the functions of the Program Status Word (PSW) register, I/O ports, and instructions like JUMP and CALL. It explains the roles of various flags in the PSW, the characteristics of each I/O port, and the differences between MOV and MOVX instructions. Additionally, it describes the pin diagram and functions of the 8051, emphasizing its use in interfacing with external devices and programming.

Uploaded by

veenakeeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

PSW (program status word) register The program status word (PSW) register is an 8-bit register.

It is
also referred to as the flag register. Although the PSW register is 8 bits wide, only 6 bits of it are used
by the 8051. The two unused bits are user-definable flags. Four of the flags are called conditional flags,
meaning that they indicate some conditions that result after an instruction is executed. These four are
CY (carry), AC (auxiliary carry), P (parity), and OV (overflow).

● CY, the carry flag


This flag is set whenever there is a carry out from the D7 bit. This flag bit is affected after an 8-
bit addition or subtraction. It can also be set to 1 or 0 directly by an instruction such as “SETB
C” and “CLR C” where “SETB C” stands for “set bit carry” and “CLR C” for “clear carry”.
● AC, the auxiliary carry flag
If there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set; otherwise, it is
cleared. This flag is used by instructions that perform BCD (binary coded decimal) arithmetic.
See Chapter 6 for more information.
● P, the parity flag
The parity flag reflects the number of 1 s in the A (accumulator) register only. If the A register
contains an odd number of Is, then P = 1. Therefore, P = 0 if A has an even number of Is.
● OV, the overflow flag
This flag is set whenever the result of a signed number operation is too large, causing the
high-order bit to overflow into the sign bit. In general, the carry flag is used to detect errors in
unsigned arithmetic operations. The overflow flag is only used to detect errors in signed
arithmetic operations
2. Explain about I/O ports and their functions in 8051.
Port-0 can be used as a normal bidirectional I/O port or it can be used for
address/data interfacing for accessing external memory. When control is ‘1’,
the port is used for address/data interfacing. When the control is ‘0’, the port
can be used as a bidirectional I/O port.
Port-1 dedicated only for I/O interfacing. When used as output port, not
needed to connect additional pull-up resistor like port 0. The pin is pulled up or
down through internal pull-up when we want to initialize as an output port. To
use port-1 as input port, ‘1’ has to be written to the latch. In this input mode
when ‘1’ is written to the pin by the external device then it read fine. But when
‘0’ is written to the pin by the external device then the external source must
sink current due to internal pull-up.
Port-2 we use for higher external address byte or a normal input/output port.
The I/O operation is similar to Port-1. Port-2 latch remains stable when Port-2
pin are used for external memory access. Here again due to internal pull-up
there is limited current driving capability.
When port 3 is used as an input port ‘1’ must be written to the corresponding
port 3 latch bit this cause the FET to turn off pin & input to pin buffer are pulled
to logic high by internal pull up load. when port 3 is used as an output the
latch pins that are programmed to o cause the lower FET to turn on the
internal pull up turn off & input to the circuit is logic 0 if a ‘1’ is written onto the
latch pin then it drive the input of external circuit high through the pull up,
lower FET turns off
3. Explain the JUMP and CALL instructions in 8051

In an 8051 microcontroller, "JUMP" instructions unconditionally transfer program


execution to a new memory address, essentially changing the program flow completely,
while "CALL" instructions temporarily transfer control to a subroutine (a small block of
code) and then return to the original execution point after the subroutine finishes,
allowing for reusable code blocks within a program.

When a "CALL" instruction is used, the current program counter (PC) value is
automatically pushed onto the stack, allowing the program to return to the next
instruction after the subroutine is completed. A "JUMP" instruction does not save
the return address, so there is no way to come back to the previous execution
point.
5.State the difference between MOV and MOVX
Instructions
MOV copies the value of source into destination. The value of source is not affected. Both destination
and source must be in Internal RAM. No flags are affected unless the instruction is moving the value of a
bit into the carry bit in which case the carry bit is affected or unless the instruction is moving a value into
the PSW register (which contains all the program flags).

MOVX moves a byte to or from External Memory into or from the Accumulator. If operand1 is @DPTR,
the Accumulator is moved to the 16-bit External Memory address indicated by DPTR. This instruction
uses both P0 (port 0) and P2 (port 2) to output the 16-bit address and data. If operand2 is DPTR then the
byte is moved from External Memory into the Accumulator.

6.Explain the Pin diagram and Pin Functions of 8051.(7MARK)


8051 microcontroller is a 40 pin Dual Inline Package (DIP).
These 40 pins serve different functions like read, write,
I/O operations, interrupts etc. 8051 has four I/O ports
wherein each port has 8 pins which can be configured as
input or output depending upon the logic state of the
pins. Therefore, 32 out of these 40 pins are dedicated to
I/O ports. The rest of the pins are dedicated to VCC, GND,
XTAL1, XTAL2, RST, ALE, EA’ and PSEN’. Pin diagram of
8051 microprocessor is as given below :

The pin diagram of the 8051 microcontroller is as follows:


1. VCC: This pin is connected to the power supply and
provides a voltage of +5V to the microcontroller.
2. GND: This pin is connected to the ground and serves as the
reference voltage for the microcontroller.
3. XTAL1 and XTAL2: These pins are used for connecting an
external crystal oscillator that provides the clock signal for
the microcontroller.
4. Reset: This pin is used for resetting the microcontroller. A
high pulse on this pin resets the microcontroller to its initial
state.
5. Port 1: This is an 8-bit bidirectional input/output port that
can be used for interfacing with external devices.
6. Port 2: This is an 8-bit bidirectional input/output port that
can be used for interfacing with external devices.
7. Port 3: This is an 8-bit bidirectional input/output port that
can be used for interfacing with external devices.
8. Port 4: This is an 8-bit bidirectional input/output port that
can be used for interfacing with external devices.
9. INT0: This is an external interrupt 0 input pin.
10. INT1: This is an external interrupt 1 input pin.
11. T0: This is an external timer 0 input pin.
12. T1: This is an external timer 1 input pin.
13. WR: This is the write signal for external memory.
14. RD: This is the read signal for external memory.
15. ALE: This is the address latch enable signal that is used
to latch the address for external memory.
16. PSEN: This is the program store enable signal that is
used for accessing the program memory.
17. 17-24. Address bus: These pins are used for
transmitting the address information to the external
memory.
18. 25-32. Data bus: These pins are used for transmitting
the data between the microcontroller and external memory.
19. RST: This is the output signal that indicates the
microcontroller is being reset.
20. EA: This is the external access enable signal that is used
for selecting the program memory.
21. VPP: This pin is used for programming the
microcontroller.
22. 36-39. XTAL: These pins are used for connecting an
external crystal oscillator.
23. P1.0 (AD0) – P1.7 (AD7): These pins are used for
interfacing with external analog devices.
Uses of pin diagram of the 8051 microcontroller :
The pin diagram of the 8051 microcontroller is used for various
purposes in embedded systems. Some of the main uses of the pin
diagram are:
1. Interfacing with external devices: The 8051
microcontroller has several input/output pins that can be
used for interfacing with external devices such as sensors,
actuators, displays, and communication modules. The pin
diagram provides the information about the location of
these pins, their functionalities, and their electrical
characteristics.
2. Programming the microcontroller: The 8051
microcontroller can be programmed using various
programming languages such as Assembly, C, and BASIC.
The pin diagram provides the information about the pins
that are used for programming the microcontroller, such as
the PSEN pin and the ALE pin.

You might also like