ESD Lab6 DARK 22ESD
ESD Lab6 DARK 22ESD
ESD Lab6 DARK 22ESD
NAWABSHAH
DEPARTMENT OF ELECTRONIC ENGINEERING
SUBJECT: EMBEDDED SYSTEM DESIGN
LAB NO: 06
Equipment Equipment Equipment Procedural Response (4) Observation’s Safety Group Score
Identification Use (4) Handling (4) Skills (4) Use (4) Adherence work (32)
(4) (4) (4)
Practice the few PIC18F instructions with the default access bank
Learning outcomes
After completion of the lab, students shall,
➢ Describe the WREG register, data RAM or File Register
➢ Practice to use the default access bank in PIC18F
➢ Follow the instructions to use PIC18F458 simple instructions with the default access bank
Lab Requirements
➢ PC with Windows Operating System
➢ MPLAB IDE v8.91
➢ MicroChip C18 Tool suite
Where D7 is the most significant bit (MSB) and D0 is the least significant bit (LSB) of the WREG
register. The WREG stands for Working REGister, as there is only one. One can compare the use of
the WREG register with the accumulator in other microcontrollers. It is used for all arithmetic and
logic instructions.
1
The PIC File Register or Data RAM
The PIC file register or data RAM is a read/write (static RAM) memory. It is also referred to as data
memory space to distinguish it from program code memory (ROM). The file register is used by the
CPU for data storage, scratch pad and registers for internal use and functions. As with WREG,
arithmetic and logical operations can be performed on many locations of the file register data RAM.
The size of the file register ranges from 32 bytes to several thousand bytes depending uponthe chip. It
must be noted that the file registers data RAM has a byte-size width. The file register in PIC is divided
into two sections.
1. Special Function Registers (SFRs)
2. General Purpose Registers (GPRs)
2
Different PIC18 microcontrollers have different sizes of file registers, however, every PIC18 has at
least one bank for the file register. This bank is called the access bank and is the default bank when
powering up the PIC18 chip.
The default access bank (256 bytes) is divided into two equal portions of 128 bytes. These 128-byte
sections are given to the general purpose registers and special function registers. The 128 bytes from
location 00H to 7FH are set aside for general-purpose registers and the other 128 bytes of the access
bank are set aside for SFRs. It has addresses of F80H to FFFH. It is shown in Figure 2.
3
IV. The ADDWF Instruction
The ADDWF adds together the contents of WREG and a file register location. The locationin the file
register can be one of the SFRs or a location in the general purpose registers. The format of this
instruction is given as
ADDWF fileReg, D
Where D indicated the destination bit. It can be either 0 or 1. If D=0, then it indicates that the result
will be stored in the WREG register or if D=1 then it puts the result in the file register. However, the
PIC assembler allows us to use the letters W or F instead of 0 or 1 to indicate the destination.
REVIEW QUESTIONS:
2. Define the role of special function registers and general purpose registers.
4
3. Define the importance and role of the WREG register in PIC microcontrollers.
4. Describe the access bank in the PIC microcontroller. What is the maximum number
of banks a PIC18 microcontroller can have?
5. Write a code to move value 09H into the WREG register. Then add 05H into it. The
result should be stored in location 25H of the file register.
6. Write a code to store your roll number in location 01H. Then copy the contents of
the 01H location to the 02H location of the file register without involving the WREG
register.
7. Write a code to send FFH to the data RAM location 25H and complement its bits
continuously forever.
8. Write a code to send a 20H value in the fileReg 01H and then add a value o f
10H to it.Store the result in the WREG register.
NOTE: Verify your code in MPLAB and attach the result of each program along with the
handout.