8051 Memory

Thread Starter

Dritech

Joined Sep 21, 2011
901
Hi all,

Can someone please explain to me why the memory is divided into three sectors (i.e. 'direct data', 'indirect data' and 'direct or indirect data' ) ?

What is saved in each of these three sectors?

Thanks in advance.
 

DickCappels

Joined Aug 21, 2008
10,170
It is not a matter of where the data are stored; it is a matter of the means of accessing the data.

With direct addressing, the data is contained in the instruction.
Example: mov a,20h This puts the value 20h into the accumulator.

With indirect addressing the data is contained at a location specified by a register.
Example: mov a, @r0 This puts the data to which register r0 points into the accumulator.



 

Thread Starter

Dritech

Joined Sep 21, 2011
901
Thanks for the reply. Am I correct in saying that address range from 0h to 7Fh can be accessed using both direct or indirect addressing, while address range 80h to FFh can only be accessed using indirect addressing?
If so, why is the memory range from 80h to FFh accessible only using indirect addressing?

Thanks in advance.
 

Papabravo

Joined Feb 24, 2006
21,225
Thanks for the reply. Am I correct in saying that address range from 0h to 7Fh can be accessed using both direct or indirect addressing, while address range 80h to FFh can only be accessed using indirect addressing?
If so, why is the memory range from 80h to FFh accessible only using indirect addressing?

Thanks in advance.
You are correct. The answer to your other question involves a clever trick. There is the possibility of having RAM from 00h to 0FFh, and in addition the SFRs are overlaid on the range 80h to 0FFh. Now for the trick, SFRs are only accessible via direct addressing. Indirect addressing in that range goes to RAM. For the range 00h to 7Fh, both types of addressing, direct and indirect, go to RAM. With 8 bits of address you get 384 different locations.

Got it?
 

Thread Starter

Dritech

Joined Sep 21, 2011
901
So in the range from 80h to FFh, the user has to use direct or indirect to indicate whether to access the RAM area or the SFR ?
The SFR is still part of the RAM right?

Another quick question related to timers. What is the meaning of "timer capture or reload"?

Thanks and sorry for my poor English.
 

Papabravo

Joined Feb 24, 2006
21,225
The Special Function Registers are different than RAM. With RAM you should always read back what you last wrote to a location. Because SFRs are connected to hardware and not memory this is not always the case. It is possible to write an SFR and read back something different.

Timer Capture refers to reading or "capturing" the value of a timer upon the occurence of a specific event, like a rising edge or a falling edge. The difference between the two values is the amount of time, in "timer ticks", between the two events.

Timer Reload is what happens when an event causes the timer to reload a particular value to create periodic events.
 

Thread Starter

Dritech

Joined Sep 21, 2011
901
Thanks for the reply. Can someone please explain what is the use of the T2OE and the DCEN bits in the T2MOD register?

Does the circuit act as a down-counter if DCEN is cleared?

I did check the 0851 datasheet but didn't understant what is actually meant by "Clear to program P1.0/T2 as clock input or I/O port. Set to program P1.0/T2 as clock output".
 
Top