Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Tutorial 2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Microcontrollers and Microprocessor Technology

Tutorial 2
Question 1 (14 pts)

Answer the following questions:

1. What is the main difference between a lab-top computer system and an


microcontroller system?
2. What is the main difference between an assembler directive and an
assembly instruction?
3. What is the difference of using the RETFIE to return from a normal
subroutine in a PIC program?

4. List the four sources of interrupts in the PIC16F84A microcontroller.


6. What is the effect of executing the following instructions?

movlw b’11110000’

movwf trisb

7. What is the binary content of the status register after executing this

instruction?

CLRF STATUS

8. Assume that the following code has just been executed.

movlw 2fh

addlw 55

a) Specify the condition of the following three status flags

C: DC: Z:

b) The binary content of the working register is _____________

9. If the INTCON register is set to A8H, then


a) Determine which interrupts are enabled?
b) An interrupt occurs, and the INTCON register is found to have changed
to A9 H, which interrupt source has called?
c) Which bit must the designer change before the end of the ISR, and why?

1
Microcontrollers and Microprocessor Technology

Question 2 (3 pts)

Three microcontrollers (A, B & C) have maximum clock speeds 10MHz, 20MHz,
24MHz respectively. Microcontroller A divides its clock by 4 to give one machine
cycle, microcontroller B by 8, and microcontroller C by 12. Microcontrollers A & C
take 2 machine cycles to perform an instruction, while microcontroller B takes
three cycles. Place the microcontrollers in order of the speed in which they can
perform that instruction?

Question 3 (2 pts)
How long does it take to execute the following instructions on a PIC 16F84A
running at a clock of 8 MHz?

goto L2

L1 movwf var1

btfss var1,0

L2 sublw 10

Question 4 (2 pts)

Outline the procedures of installing a program in a microcontroller during your


project design?
Question 5

In the following code, explain what each instruction does and give the content of
the registers involved after the execution of the said line of codes. Calculate the
total tome of execution if the controller frequency is 4MHz

BSF     03h,5            ;Go to Bank 1


     MOVLW   06h              ;Put 00110 into W
     MOVWF   85h              ;Move 00110 onto TRISA
     BCF     03h,5            ;Come back to Bank 0

2
Microcontrollers and Microprocessor Technology

Question 6

In the following code, calculate the total tome of execution if the controller
frequency is 20MHz

COUNT1 equ 08h ; timing for the Delay1 and the Delay2
COUNT2 equ 09h
COUNT3 equ 01h
COUNT4 equ 02h

; set up all ports as outputs


movlw b'0'
movwf TRISA
movwf TRISB
movwf TRISC
movwf TRISD
movwf PORTD

; begin program here:

Start

Flash ; part one to repeat 5 times.


movlw b'10100'
movwf PORTB
movlw b'1011111'
movwf PORTD
movlw b'0'
movwf PORTA
movlw b'0'
movwf PORTC

call Delay1 ; center flash on

movlw b'10001111'
movwf PORTD
movlw b'111110'
movwf PORTA
movlw b'1'

3
Microcontrollers and Microprocessor Technology

movwf PORTB
movlw b'11000111'
movwf PORTC

call Delay1 ; center flash off, outer ring on

movlw b'10100'
movwf PORTB
movlw b'1011111'
movwf PORTD
movlw b'0'
movwf PORTA
movlw b'0'
movwf PORTC

Goto Start

Delay1 ; Delay here for the first flashing part. Subprogram 1


Loop1 decfsz COUNT1,1
goto Loop1
decfsz COUNT2,1
goto Loop1
return

Delay2 ; Delay here for the spinning part. Subprogram 2


Loop2 decfsz COUNT3,1
goto Loop2
decfsz COUNT4,1
goto Loop2
return

end

You might also like