Unformatted text preview:

Lab 2Part I: General knowledge. 1. Open PIC18 Simulator IDE. Make sure the device is set to PIC184522. Run the program on page 542 using the Program Memory Editor. 3. After you finish executing the program, specify the value of the following registers: PC WREG PORT C TRISC LATC4. Using Table 3-1, specify the SFR for PORT C. 5. Using Table 3-1, specify the SFR for TRISC.6. What is the value of register FE8 in the SFRs? What is it called? 7. What is the value of register FD8 in the SFRs? What is it called? 8. What is the value of register FE0 in the SFRs? What is it called? Part II: Practice 1. Open PIC18 Simulator IDE. 2. Clear the memory. 3. Write the value of following registers. PC WREG PORT C TRISC LATC4. Identify the value of the following registers after each command: # Opcode + Operant PC WREG Reg. Address Reg. Content 1 MOVLW 0XF22 MOVWF 0X25,03 MOVFF 0X25,0X26a. Which of the commands above is considered to be direct addressing?b. Which command represents immediate addressing?c. Clear the memory in the program. 5. Identify the value of the following registers after each command: Opcode + Operant PC WREG Reg. 0x05 Content Status Reg (binary)MOVLW 0X5ADDLW 0X3FADDWF 0X5,1,0ADDWF 0X5,0,0ADDWF 0X5,F,0INCF 0X5,0,0INCF 0X5,1,06. Which flag is set in the status register after the program is competed?Part III: Program In this section you are about to write a series of instructions such that after the program is executed the following can be observed (you can use the assembler and write all the commands in order):a. Reg 0xA=0x12; b. Reg 0xB=0x13; c. Reg 0xC=0x14; d. Reg 0xD=0x28; e. Reg 0xE=0x28; List your program in the table below and complete each column properly. Opcode + Operant PC WREG Reg Add / Reg Content Status Reg (binary)2. Show snapshots of the simulator to verify the correctness of your program in each case.Part IV: Program 1- Make sure the STATUS register is set to zero. Which status bits will be set after running the following commands? Explain your answer. MOVLW 0x88 SUBLW 0x882- In question above change the code such that REG2 indicates register 2. Then save the STATUS register content into REG2 register. Take a snapshot of the results. Show your code and the results. Don’t forget comments. 3- In this section you are about to write a series of instructions such that after the program is executed the following can be observed (you can use the assembler and write all the commands in order):a. Only OV bit in the STATUS register is set. b. Only DC bit in the STATUS register is set. c. Only Z bit in the STATUS register is set. d. What will be the status of STATUS register when you execute: CRLF STATUS command?4- What is the fastest way (in terms of clock cycles) to clear the STATUS register? 5-Write the appropriate instruction for each task. Instruction CommentSet REG12 as register 0xOCClear REG12Set bit 6 of REG12; WHAT HAPPENED TO STATUS REG?Toggle bit 6 of REG12; WHAT HAPPENED TO STATUS REG?IOR REG12 and value 0x80Make REG12 = 0 and at the same time set Carry bit in STATUS=16- Consider the following two sets of commands. In each case explain what will be the value of W, REG2, andSTATUS register: Explain your Answer. CLRF STATUSMOVLW 0x80MOVWF REG2RLCF REG2,0 CLRF STATUSMOVLW 0x80MOVWF REG2RLCF REG2,1W= W=STATUS= STATUS=REG2 REG27- Consider the following two sets of commands. In each case explain what will be the value of W, REG_2F, and STATUS register: Explain your answer. CLRF STATUSMOVLW 0x04MOVWF BSRMOVWF REG_2F,1CLRF STATUSMOVLW 0x04MOVWF BSRMOVWF REG_2FW= W=STATUS= STATUS=REG_2F REG_2F8- Use the code below and connect PORTB to the Stepper Motor in the Simulator. Observe what is happening.Find some information about Stepping Motors and see if you can make the motor turn continuously. Do not use IF/LOOP/WHILE or any conditional statement. YOU MUST DEMONSTRATE THIS IN CLASS. MOVLW 0X1MOVWF REG2MOVLW 0X00MOVWF TRISB,0 CLRF PORTBMOVFF REG2,PORTBSTARTA: RLNCF REG2,F,0MOVFF REG2,PORTBRLNCF REG2,F,0MOVFF REG2,PORTBINCF REG2,F,0MOVFF REG2,PORTBGOTO


View Full Document

SSU ES 310 - ES 310 Lab 2

Download ES 310 Lab 2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view ES 310 Lab 2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view ES 310 Lab 2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?