µVISION DEBUGGER: DIFFERENCE BETWEEN SFR AND VTREG
Information in this article applies to:
I don't understand the difference between SFRs and VTREGs.
An SFR is a Special Function Register that is an integral part of the chip you use. The SFR may be programmed to configure the chip or an on-chip peripheral. The embedded programs you write will certainly use some SFRs.
A VTREG is a Virtual Target REGister. This register is NOT directly affected by or accessible to your embedded program. A VTREG is a register that is available only in the simulator. It allows you to change the state or a pin on the simulated device. You may only change a VTREG in the Command Window of the µVision Simulator or in a script that runs in the µVision Simulator.
Your target program may use I/O Port 1 to read the value of some switches. To do that, it must read the P1 SFR.
When you test your program with the µVision Simulator, you may want to set or clear some of the "simulated switches" on Port 1. To do that, you need to change the state (or input level) on the Port 1 input pins. That's what VTREGs allow you to do. The PORT1 VTREG is the value of the pins of Port 1. If you set the PORT1 VTREG to a value of 0xAA (by typing PORT1=0xAA in the Command Window), your target program will read 0xAA from the P1 SFR.
The following Discussion Forum threads may provide information related to this topic.
Last Reviewed: Wednesday, June 30, 2004