0% found this document useful (0 votes)
11 views15 pages

CCE 131-Lecture 6

Uploaded by

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

CCE 131-Lecture 6

Uploaded by

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

Computer Organization

CCE131
Lecture 6

8051 Microcontroller-3

Dr. Emad Badry


Lecturer at faculty of Engineering, Suez Canal University
emad.badry@eng.suez.edu.eg
I/O Port Programming
❑ All the ports upon RESET are configured as input, ready to be used as input ports.
❑ When the first 0 is written to a port, it becomes an output. To reconfigure it as an input, a 1 must be sent to the port.

In order to make port 0 an input, the port must be programmed by writing 1 to all the bits.
Port 1 can be used as input or output. To make port 1 an input port, it must be programmed as such by writing 1 to all its
bits.

Alternative method
I/O Bit Manipulation Programming
Example
Instructions for Reading an Input Port

Example
SFR Registers

❑ The SFR (Special Function Register) can be accessed by their names or by their addresses.

❑ The SFR registers have addresses between 80H and FFH. The unused locations 80H to FFH are reserved and must
not be used by the 8051 programmers.
Special Function Register (SFR) Addresses
Example
Register Indirect Addressing Mode

❑ A register is used as a pointer to the data. Only register R0 and R1 are used for this purpose.

❑ R2 – R7 cannot be used to hold the address of an operand located in RAM.


❑ When R0 and R1 hold the addresses of RAM locations, they must be preceded by the “@” sign.
Example
Example

❑ R0 and R1 are the only registers that can be used for pointers in register indirect addressing mode. Since R0 and R1
are 8 bits wide, their use is limited to access any information in the internal RAM. Whether accessing externally
connected RAM or on-chip ROM, we need a 16-bit pointer. In such case, the DPTR register is used.
Register Indirect Addressing Mode

❑ Indexed addressing mode is widely used in accessing data elements of look-up table entries located in the program ROM.
❑ The instruction used for this purpose is MOVC A,@A+DPTR. Use instruction MOVC, “C” means code

❑ The contents of A are added to the 16-bit register DPTR to form the 16-bit address of the needed data.
Example
Example

You might also like