Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[51] Dynamic Reading of SFR in 8051

Status
Not open for further replies.

arv09

Newbie level 3
Joined
Jul 7, 2014
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
48
I have been coding in Assembly for a couple of months now. I started with 8051 and I am now using a Microcontroller (Nuvoton) which is an 8051 derivative.

For debug purposes, I want to view the SFR values at runtime. I have 4 seven segment for my application. I can view the 256 bytes of RAM with the below code in the 7 segment displays

Code:
MOV R0,regloc
MOV A,@R0

regloc is a register location in RAM. When pressing a key, this regloc is made to scroll from 0 to 255. So depending on the value at regloc, the corresponding value from the internal 256 bytes of RAM is displayed. 2 of the 7-segment digits display the regloc in Hexa (00 to FF) and the other 2 7-segment displays the RAM value at that regloc location.

Similarly, I want to view the SFR's too. The Nuvoton Microcontroller (N79E855) that I'm using currently has more number of SFR's than 8051.
To view these, when I use similar logic and tried following code

MOV R0,regloc
MOV A,R0

What this does is, it loads to accumulator the value at regloc and not the SFR. I can understand that what I'm doing is loading the accumulator with the value at regloc address.

MOV A,PSW
(OR)
MOV A,D0h

While the above two lines would load into ACC, the value at PSW, I'd like to know if I can read the SFR's sequentially like reading the RAM. I hope this is all clear and someone can let me know if this can be done or the only way is direct addressing method
 

The data sheets explain the methods of accessing internal ram as the following:

The "8051" has 128 bytes of on-chip RAM, plus a number of Special
Function Registers (SFRs).
The lower 128 bytes of RAM can be
accessed either by direct addressing (MOV data addr) or by indirect
addressing (MOV @Ri).
The SFR's can only be accessed by direct addressing (MOV data addr).

The example you gave below is indirect addressing.
Code:
MOV R0,regloc
MOV A,@R0

The second example you gave is direct addressing.
Code:
MOV A,PSW
(OR)
MOV A,D0h
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top