Internal RAM Structure of 8051 | Bit Addressable Area & General Purpose Area of Internal RAM in 8051

Engineering Funda
16 Aug 202209:02

Summary

TLDRThis video lecture delves into the internal RAM structure of the 8051 microcontroller, detailing its 128-byte capacity divided into three regions: the register bank area, bit-addressable RAM, and general-purpose RAM. It explains how to select register banks using PSW bits and execute instructions specific to the chosen bank. The video also covers bit-addressable operations and the utilization of the general-purpose area for stack operations and subroutines, offering insights into the microcontroller's memory management.

Takeaways

  • 📘 The 8051 microcontroller has an internal RAM of 128 bytes, divided into three distinct regions: Register Bank, Bit Addressable RAM, and General Purpose RAM.
  • 🔢 The Register Bank consists of 32 bytes, with four banks (Bank 0 to Bank 3), each containing eight registers (R0 to R7), and is selected using the PSW (Program Status Word) RS bits.
  • 📍 The addresses for the Register Banks are Bank 0: 00h to 07h, Bank 1: 08h to 0Fh, Bank 2: 10h to 17h, and Bank 2: 18h to 1Fh.
  • 🎯 The Bit Addressable RAM area spans 16 bytes from 20h to 2Fh, allowing for operations to be performed on individual bits within these bytes.
  • 🤖 The 128 bits in the Bit Addressable area can be addressed individually, offering both byte-wise and bit-wise operations.
  • 🔧 The General Purpose RAM area, also known as Scratchpad RAM, comprises 80 bytes from 30h to 7Fh and is used for various purposes as determined by the programmer.
  • 🛠️ Instructions like 'MOV A, R0' depend on the selected Register Bank, which can be identified by the RS bits in the PSW register.
  • 📝 Direct addressing can be used for certain operations, such as 'MOV A, #08h', which copies data from a specific address in RAM to the accumulator.
  • 🔄 The stack pointer holds the address of the top of the stack within the internal RAM and is used for 'PUSH' and 'POP' operations.
  • 🔑 The default Register Bank is Bank 0, but programmers can select other banks using the PSW RS bits, affecting which R0 to R7 registers are accessed.
  • 📚 Understanding the internal RAM structure of the 8051 microcontroller is crucial for effective programming and utilizing its features.

Q & A

  • What is the total size of the internal RAM in a microcontroller 8051?

    -The total size of the internal RAM in a microcontroller 8051 is 128 bytes.

  • How is the internal RAM of the 8051 microcontroller divided?

    -The internal RAM of the 8051 microcontroller is divided into three regions: the register bank region, the bit-addressable RAM area, and the general-purpose RAM area.

  • How many register banks are there in the 8051 microcontroller, and what are their sizes?

    -There are four register banks in the 8051 microcontroller, each containing eight registers (R0 to R7), totaling 32 bytes.

  • What is the purpose of the PSW 0.3 and PSW 0.4 bits in the 8051 microcontroller?

    -The PSW 0.3 and PSW 0.4 bits are used to select the register bank in the 8051 microcontroller. By setting these bits, the programmer can choose between Bank 0, Bank 1, Bank 2, or Bank 3.

  • How can you determine which register bank is currently selected when executing instructions?

    -The currently selected register bank can be determined by the state of the RS bits (PSW 0.3 and PSW 0.4). The default bank is Bank 0, but it can be changed by setting these bits accordingly.

  • What is the address range of the bit-addressable RAM area in the 8051 microcontroller?

    -The bit-addressable RAM area in the 8051 microcontroller starts from address 20h and goes up to 2Fh, totaling 16 bytes.

  • How many bits are there in the bit-addressable RAM area of the 8051 microcontroller?

    -There are 128 bits in the bit-addressable RAM area of the 8051 microcontroller, as it consists of 16 bytes, and each byte has 8 bits.

  • Can you perform both bytewise and bitwise operations on the bit-addressable RAM area?

    -Yes, you can perform both bytewise and bitwise operations on the bit-addressable RAM area, although the area is specifically designed for bitwise addressing.

  • What is the purpose of the general-purpose RAM area in the 8051 microcontroller?

    -The general-purpose RAM area, also known as scratchpad RAM, is used for temporary storage of data and can be utilized by the programmer for various purposes, such as stack operations, subroutine calls, and ISRs.

  • What is the address range of the general-purpose RAM area in the 8051 microcontroller?

    -The general-purpose RAM area in the 8051 microcontroller ranges from address 30h to 7Fh, totaling 80 bytes.

  • What is the role of the stack pointer in the internal RAM of the 8051 microcontroller?

    -The stack pointer holds the address of the top of the stack within the internal RAM of the 8051 microcontroller and is used for push and pop operations.

Outlines

00:00

📚 Introduction to 8051 Microcontroller's Internal RAM Structure

This paragraph introduces the topic of the 8051 microcontroller's internal RAM structure. It explains that the internal RAM is 128 bytes in size, with addresses ranging from 00h to 7Fh. The RAM is divided into three regions: the Register Bank area, the bit-addressable RAM area, and the general-purpose RAM area. The paragraph also mentions the concept of selecting a Register Bank using the PSW (Program Status Word) bits RS0 and RS1, and provides an example of how to change the active Register Bank using assembly instructions.

05:01

🔍 Detailed Explanation of Bit-Addressable and General-Purpose RAM in 8051

The second paragraph delves deeper into the bit-addressable RAM area, which consists of 16 bytes that can be addressed individually as 128 bits, with addresses ranging from 20h to 2Fh. It explains how to perform bit-wise operations on these locations, such as setting or clearing specific bits. The paragraph also discusses the general-purpose RAM area, which is a larger section of 80 bytes (from 30h to 7Fh) that can be used flexibly by the programmer for various purposes, including stack operations, subroutine calls, and ISR (Interrupt Service Routines). The importance of understanding the stack pointer, which holds the address of the top of the stack within the RAM, is highlighted, with a promise to cover this topic in a future video.

Mindmap

Keywords

💡Microcontroller 8051

The Microcontroller 8051 is a specific type of microcontroller, which is a small computer on a single integrated circuit. It is known for its simplicity and efficiency, making it a popular choice for various embedded systems. In the video, the internal RAM structure of this microcontroller is the main focus, highlighting its significance in understanding how the device operates and stores data.

💡Internal RAM

Internal RAM, or Random Access Memory, refers to the memory inside a microcontroller where data can be read from and written to directly. In the context of the 8051 microcontroller, the script explains that it has 128 bytes of internal RAM, which is divided into different regions for specific purposes, such as register banks, bit-addressable RAM, and general-purpose RAM.

💡Register Bank

A Register Bank in the context of the 8051 microcontroller is a collection of registers that are used to store data temporarily. The script mentions that there are four register banks (Bank 0 to Bank 3), each containing eight registers (R0 to R7). These banks are crucial for data manipulation and are selected using the PSW (Program Status Word) bits.

💡PSW (Program Status Word)

PSW is a special register in the 8051 microcontroller that contains status flags and control bits. The script explains that two bits of the PSW, specifically bits 0.3 and 0.4, are used to select the active register bank, which determines which set of registers (R0 to R7) the programmer is currently working with.

💡Bit-addressable RAM

Bit-addressable RAM is a section of memory where each bit can be accessed individually. The script specifies that the 8051 microcontroller has 16 bytes of bit-addressable RAM, ranging from addresses 20H to 2FH. This feature allows for more granular control over data, enabling operations on individual bits rather than entire bytes.

💡General Purpose RAM

General Purpose RAM, also known as scratchpad RAM, is a section of memory that can be used for any purpose the programmer defines. The script mentions that the 8051 microcontroller has 80 bytes of general-purpose RAM, which can be utilized for various tasks such as storing temporary data or managing subroutines and interrupts.

💡Stack Pointer

The Stack Pointer is a register in the 8051 microcontroller that holds the address of the top item on the stack. The stack is a region of memory used to store temporary data during function calls or interrupt handling. The script indicates that the stack pointer will be discussed in more detail in a future video, emphasizing its importance in managing the microcontroller's memory operations.

💡Instruction Execution

Instruction execution refers to the process by which a microcontroller carries out the operations specified by its program instructions. The script gives examples of how instructions interact with the internal RAM, such as copying data from a specific register (e.g., 'MOV A, R0') or directly addressing a memory location (e.g., 'MOV A, #08H').

💡Bitwise Operations

Bitwise operations are operations that act on the individual bits of a byte or word. The script explains that in the bit-addressable RAM area, instructions like 'SETB 7FH' set a specific bit, while 'CLR 08H' clears a bit. These operations allow for precise manipulation of data at the bit level.

💡Memory Addressing

Memory addressing refers to the method by which a microcontroller accesses specific locations in memory. The script discusses different addressing modes, such as direct addressing (e.g., 'MOV A, 17H') and indirect addressing through the use of registers, which is essential for understanding how data is retrieved and stored within the microcontroller's RAM.

Highlights

Introduction to the internal RAM structure of the microcontroller 8051.

The size of internal RAM in the 8051 microcontroller is 128 bytes.

Internal RAM is divided into three regions: Register Bank, bit-addressable RAM, and general-purpose RAM.

There are four Register Banks (Bank 0 to Bank 3), each with eight registers.

Register Banks occupy 32 bytes with addresses ranging from 00h to 1Fh.

Bank selection is controlled by PSW 0.3 and PSW 0.4 bits.

Instructions execution depends on the selected Register Bank.

Direct address writing is possible for accessing specific registers.

16 bytes of bit-addressable RAM start from address 20h to 2Fh.

128 bits are available for bit-addressable operations.

Bit-addressable RAM allows both bytewise and bitwise operations.

General-purpose RAM area spans from 30h to 7Fh, totaling 80 bytes.

The programmer must decide how to utilize the general-purpose RAM area.

The stack pointer holds the address of the top of the stack within the internal RAM.

Future videos will explain the stack pointer's role in push and pop operations.

The video aims to provide a clear understanding of the 8051 microcontroller's internal RAM structure.

Transcripts

play00:00

welcome to engineering Funda family this

play00:02

video is a part of microcontroller 8051

play00:05

video lecture series and in this video

play00:07

I'll be going to explain you internal

play00:09

Ram structure of microcontroller 8051

play00:13

here there are few basic things that you

play00:15

should know regarding how internal

play00:17

structure is there with ram first of all

play00:19

let me tell you what is the size of

play00:20

internal Ram with microcontroller 8051

play00:23

see that size is of 128 byte so

play00:27

obviously address will start from 0 0

play00:29

hex it will go up to 7 F hex 0 0 means 0

play00:33

7 f means 127 so 0 to 127 means in total

play00:38

128 bytes are there with internal Ram of

play00:42

8051 those 128 bytes are bisected into

play00:46

three regions first is resistor Bank

play00:49

region second is based on bit

play00:52

addressable Ram area and third is there

play00:56

for general purpose scratch paid Ram

play01:00

how it is there let us see all those

play01:02

things step by step along with examples

play01:04

so here let me explain you first how

play01:07

resistor Bank area is there with Ram

play01:09

with 8051 so here we have in total four

play01:13

resistor banks that you should know Bank

play01:16

0 Bank 1 Bank 2 Bank 3. each resistor

play01:19

bank is having eight resistors r0 to R7

play01:23

you see it is written over here

play01:26

Bank 0 is having address from 0 0 hex to

play01:29

zero seven hex Bank 1 is having address

play01:32

from 0 8 to 0 f bank 2 is having address

play01:35

from 1 0 to 1 7 and Bank 3 is having

play01:38

address from one eight to one F in total

play01:42

32 bytes are there But Here My Dear

play01:45

students when you write program at that

play01:47

time first of all you will have to

play01:49

select the bank by default it will be

play01:51

having Bank zero but as if programmer

play01:54

wants to use any other bank then by

play01:57

using two bits PSW 0.3 PSW 0.4 those are

play02:02

rs bit of lag resistor by using this two

play02:05

bit we can select any resistor Bank

play02:09

here for example as if I write CLR PSW

play02:12

0.4 what I do is I am clearing this bit

play02:16

means this bit is zero when I write satb

play02:19

PSW 0.3 means I am setting this bit PSW

play02:24

0.3 what it means RS is 0 1 now RSA 0 1

play02:28

means what now I have selected bank one

play02:31

so now bank once resistors that is

play02:34

getting selected as per r0 to R7 right

play02:38

now my dear students when you execute

play02:42

instructions at that time also there are

play02:43

few interesting things that you need to

play02:46

note down for example when you write

play02:48

move a comma r0 what you do simply you

play02:50

are copying the data of r0 inside a but

play02:53

do you know which r0 that you are having

play02:55

for that you need to know what is my RS

play02:58

bits by default obviously it will be 0 0

play03:00

for Bank 0 right by default it will be

play03:03

taking this address 0 0 means r0's data

play03:06

inside this resistor Bank but as if you

play03:11

have this PSW 0.3 and PSW 0.4 as per

play03:16

other bits means as if I say RS is

play03:18

equals to 1 0 means bank 2 will be

play03:21

selected and Bank 2's are 0 is having

play03:25

address 1 0 hex Bank zeros are 0 is

play03:28

having address 0 0 hex that is how it is

play03:30

there right so here you can execute this

play03:33

instruction there is no doubt based on

play03:35

that but here you should know

play03:37

which bank that we have selected

play03:40

initially by default obviously it will

play03:42

be Bank zero but you can change that

play03:44

also right now here one more thing that

play03:47

you need to know like you can execute Mo

play03:49

a comma 0 8 hex now it is not like you

play03:53

are copying 0 8 inside a my dear

play03:56

students to copy 0 8 hex inside a you'll

play04:00

have to write hashtag over here here I

play04:02

have not written hashtag what it means

play04:04

this is address which address Ram's

play04:07

address so you see 0 8 hacks that is a

play04:12

Rams address which is holding r0 inside

play04:15

Bank 1 that is having whatever data that

play04:19

I can copy inside a

play04:22

so directly address also can be written

play04:24

it is not like you will have to select

play04:26

resistor Bank like for example is a as

play04:29

if I write 1 7 hex over here then 1 7

play04:33

hacks

play04:34

that is R7 of bank 2. so that data which

play04:39

is there with R7 of bank 2 that we will

play04:41

be copying inside a as if you write this

play04:44

instruction right so directly address

play04:46

can be written over here

play04:48

now my dear students let me explain you

play04:51

second area of internal Ram that is bit

play04:53

addressable area

play04:55

here you see we have 16 bytes which are

play04:58

bit addressable over here it is starting

play05:00

from 2 0 hex to 2 F hex right in total

play05:04

16 bytes are there which can be

play05:06

addressed as per bit

play05:08

Here My Dear students how many bits are

play05:11

there with this 16 bytes obviously 16

play05:13

into 8 means 128 bits are there

play05:17

how to address this so obviously it will

play05:20

start from 0 0 it will come over here up

play05:22

to 0 7 means 20 hex that is having 0 to

play05:27

0 7 bit address then 21 hex that is

play05:32

having address from 0 8 to 0 f that is

play05:34

how

play05:35

up to 2fx that is having 7 f 2 7 8 hex

play05:41

bit addressable that is how it is there

play05:43

so here you can address that as per bit

play05:45

as well as byte but spatially bit

play05:48

addressable that I have mentioned the

play05:50

reason is this

play05:52

memory locations that can be addressed

play05:55

as per bits all these memory locations

play05:57

cannot be addressed as per bits right

play05:59

bytewise operation can be done but

play06:02

bitwise is also possible

play06:04

let me explain you few examples like

play06:07

when you execute set B 7 F hex what you

play06:12

do see 7f hex means MSB of 2f hex that

play06:18

is this bit MSB only right single bit so

play06:22

this bit that will get set over here

play06:24

when you execute this for example let me

play06:27

execute

play06:28

clr08 hex what you do you will be

play06:31

clearing this bit which is having

play06:34

position 0 at hex 0 at X is over here

play06:37

that is LSB of 2 1 hex so that bit will

play06:42

get clear so single bit clear that can

play06:45

be done over here for example when you

play06:48

write Mo to 0 hex comma hashtag FFX then

play06:54

what do you do Here My Dear students at

play06:57

2 0 hacks

play06:58

you will be copying this data this data

play07:02

is what all ones so eight ones are there

play07:06

all eight ones that will be copying at

play07:09

the address to 0 hex so 2 0 hex is

play07:12

having this bits all bits will become 1

play07:15

after this so bytewise operation is also

play07:17

possible but bitwise is also possible

play07:20

this is basically used for bit

play07:22

addressable area right all the resistors

play07:26

as well as all the locations that can be

play07:28

performed with respect to byte but bit

play07:31

wise spatially this addresses are only

play07:33

available right so this 16 bytes in

play07:36

total 128 bits that can be used as a bit

play07:40

addressable with the internal Ram

play07:42

structure of 8051 microcontroller now

play07:45

third

play07:47

category that is general purpose area in

play07:49

Ram that is also referred as scratch

play07:51

bedroom you see three zero hex to 7fx in

play07:54

total 80 bytes are there that we can use

play07:56

it for general purpose Here My Dear

play07:59

students first of all programmer will

play08:00

have to

play08:01

to decide how to use this it is not like

play08:04

automatically things will happen right

play08:06

here programmer will have to program

play08:08

things in such a way so that programmer

play08:11

can use this general purpose area right

play08:13

so here by using push and pop

play08:15

instruction you can use this as well as

play08:17

in call subroutine as well as in ISR

play08:20

this area can be utilized right so here

play08:23

in total 128 bytes are there 32 bytes

play08:27

are there for resistor Bank 16 bytes are

play08:30

there for bit addressable RAM and 80

play08:32

bytes are therefore general purpose

play08:34

right and this is how internal rhyme

play08:36

structure is there and one more

play08:38

essential thing that you need to know

play08:40

down like stack pointer that will be

play08:43

holding address of top of Stack that is

play08:45

that inside this Ram only right and that

play08:49

is used for push and pop so that is also

play08:52

I'll explain you in future coming video

play08:54

so that you will be having fair enough

play08:55

idea about this I hope it is clear to

play08:57

you still if any confusion is just post

play08:59

that in the next I'll be happy to help

play09:00

you thank you so much for watching this

play09:01

video

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
Microcontroller8051Internal RAMEngineeringEducationalMemory BanksBit AddressableGeneral PurposeScratchpadInstruction Set
Benötigen Sie eine Zusammenfassung auf Englisch?