RAM allocation in 8051?
There are 128 bytes of RAM in the 8051. The RAM in 8051 are assigned address 00 to 7FH.
- 32 bytes from 00 to 1F hex are assigned for register banks and the stack.
- 16 bytes from 20H to 2FH are assigned for bit addressable read/write memory.
80 bytes from 30H to 7FH are assigned for read/write storage, normally called as scratch pad
About 8051 Register banks?
The 32 bytes of RAM space is set aside for Register banks, and these Register banks are divided into 4 Banks each bank has 8 registers, R0- R7.
In RAM space 00 – 07 are set aside for Bank 0 of R0 – R7 registers. And the remaining 3 banks also allocated in the RAM space refer RAM allocation diagram.
By default the Register Bank 0 is accessed when the 8051 power up.
How to switch the Register Banks ?
When the 8051 is power up by default Register bank 0 is selected. Switch from Bank 0 to other bank with the help of PSW (Program status word) register. Bits D4 and D3 are used to select the desired register bank as Bank 0 or Bank 1 or Bank 2.
Stack in the 8051?
The stack in the 8051 is used to store the information temporarily.
The register used to access the stack is called Stack Pointer (SP) register. The stack pointer in the 8051 is 8 bits wide, which means it can take values of 00 to FFH. The stack pointer point to location 07 when the 8051 is power up.
What is the Difference b/w below two instructions?
- MOV A, 10H;
- MOV A, #10H;
MOV A, 10H means to move into A the value held in memory location “10H”.
MOV A, #10H means to move into A the value “10H”.
The pound (#) sign is preceding any value the assembler assumes it’s a value .if pound(#) sign not preceded into any value the assembler assumes it’s a memory location.
8051 Pin Diagram/Information?
The 8051 is 40 pin chips. It has four ports for I/O operations, a total of 32 pins are set aside for the four ports P0, P1, P2 and P3, where each port takes 8 pins.
The rest of the pins are designated as Vcc, GND, XTAL1, XTAL2,RST, EA, ALE/PROG and PSEN.
The pin diagram as below.
Port 0 occupies a total of 8 pins (in 32- 39).it can be used for input/output. Each pin is connected to 10K ohm pull up resistors.
In order to make it an input port the port must be programmed by writing 1 to all the bits.
It can be used for both Input & Output. It can be used as for both address and data.
Port 1/ Port 2:
It can be used as Input/output. Upon reset, port 1 is configured as an input port. If port 1 is configured as an output port, to make it input port again ,it must be programmed as such write 1 to all the bits.
It occupies total 8 pins through 10 to 17. It can be used as Input/output port.
Port 3 has the additional function of providing some important signals Interrupts, Timers..
P3.0 and P3.1 are used for the RXD and Txd serial communication signals.
P3.2 and P3.3 are set aside for external interrupts.
P3.4 and P3.5 are used for Timers (T0, T1)
P3.7 is used for Read/Write operation (WR/RD).