Microcontrollers and Interface Programming (CSCT6102)
Computer Science - COS
Semester: First Semester
Level: 400
Year: 2013
1
HTTTC Bambili Computer Science Department
Continuous Assessment
Course: PIC MICROCONTROLLER PROGRAMMING
2012-2013 academic year
Exercise 1: (7.5 marks) This is an assembler program
list p=16f84 , r=dec
#include "p16f84.inc"
bcf STATUS,RP0
bcf STATUS,RP1
movlw 'D'
movwf 24h
bsf STATUS,RP0
movlw 'A'
movwf 0xA1
bcf STATUS,RP0
bsf STATUS,RP1
movlw 'D'
movwf 114h
bsf STATUS,RP0
movlw 'D'
movwf 192h
end
1. Explain the following instructions (2 marks)
a) movwf 192h
b) movlw 'A'
c) bcf STATUS,RP0
d) #include "p16f84.inc"
2. What do you think this program does? (0.5 mark)
3. Why do you think it is necessary to move from a bank to another? (0.5 mark)
4. The following figure shows how the program is stored in a RAM, using MPLAB software.
4.a) Give the coding of letters A and D in hexadecimal (1 mark)
www.schoolfaqs.net
2
4.b) Give also coding of STATUS, RP0 and RP1 (1.5 mark)
5. These are two instructions: bcf 0x3,0x5 and bcf STATUS,RP0
5.a) Are those two instructions different? (0.5 mark)
5.b) Give the role of instruction #include P16F84.inc (0.5 mark)
6. From the figure, one can remark that instruction movwf 192h has become movwf 0x12 . It is normal?
Give the number of bits used. Identify the value of RP1 and RP0 (1 mark).
Exercise 2: (5 marks)
a) Give the difference between these two instructions:
decfsz X1,f and decfsz X1
b) With table 2 above, give the formula in term of N1, N2 describing the time T given by this program.
Calculate T.
N1 equ 240
N2 equ 245
Wasting:
bcf status, RP0
movlw N1
movwf X1
movlw N2
movwf X2
Wait1:
decfsz X1,f
NOP
NOP
Wait2:
desfsz X2,f
NOP
goto Wait2
NOP
goto Wait1
Return
Exercise 3: (5 marks) This is a print screen program memory deliver by MPLAB for a PIC 16F84.
Write the assembler program that has been used.
www.schoolfaqs.net
3
Exercise 4: (2.5 marks) With table 2 below, give the formula of the time T describing this program, in
term of N:
movlw N
movwf 66h
HERE: desfsz 66h,f
NOP
goto HERE
end
Table 1: Bank codes
RP1 RP0 Selected bank
0 0 Bank 0
0 1 Bank 1
1 0 Bank 2
1 1 Bank 3
Table 2: Number of cycle of instruction
Instruction bcf bsf movwf movlw Nop Goto call return decfsz Assign
variable
Number
of cycle
1 1 1 1 1 2 2 2 1 1
www.schoolfaqs.net