Microcontrollers and Interfaces Programming (CSCT6102)

Computer Science - COS

Semester: First Semester

Level: 500

Year: 2013

1 /3
HTTTC Bambili Computer Science Department
Continuous Assessment
Level 400
PIC MICROCONTROLLER PROGRAMMING
2013-2014 academic year
Duration: 2 hours
Exercise 1: (4 marks)
Using the table below and figure 1, write an assembler program able to store in a microcontroller, the
decimal number 20, 40 and 50 respectively at position 73h, 174h and 185h.
Exercise 2: (6 marks)
Let us consider the program below:
N1 equ 240
N2 equ 245
Waisting:
movlw N1
movwf X1
movlw N2
movwf X2
clrf X1;
clrf X2,
Wait1:
NOP
NOP
NOP
Decfsz X1,1
Goto Wait1
Wait2:
NOP
NOP
decfsz X2,1
Goto Wait2
Return
a) With table at the end of this document, give the formula in term of N1, N2 describing the number
of cycles given by this program.
b) Calculate the correspondent time T by assuming that the microcontroller is working at effective
frequency 4MHz.
c) Do you think that the values of N1 and N2 given at the beginning are necessary? Why?
www.schoolfaqs.net
2 /3
Exercise 3: (10 marks) Let us consider the table below representing the sequences of a junction light. Only
the diodes lighting are representing in the table.
Sequences 1, 2, 3 Green 1 Red 2
Sequence 4 Yellow 1 Red 2
Sequence 5,6 Red 1 Green 2
Sequence 7 Red 1 Yellow 2
The junction traffic light is represented as follow:
a) Suggest an electronic circuit able to manage that project, using a PIC16F84A microcontroller.
b) Use ISIS Proteus to design that electronic circuit.
c) Write a program in an environment of your choice (MPLAB environment), build and flash it into the
PIC16F84A.
d) Simulate and call the examiner as you succeed.
www.schoolfaqs.net
3 /3
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 cycle and 2
cycles to skip
1
Figure 1: PIC 16F62x RAM organization
www.schoolfaqs.net