Please can my answer be completed in a word/ excel type document. Thanks for looking at my question
An assembler program has been written for a PIC 16F84 microprocessor which ‘flashes LEDs’ through a left or right sequence. The sample code for scenario tasks 1-4 is as follows:
; U19A2T1-4.asm
; blinks LEDs on outputs in a rotating pattern, with input option to reverse direction
;Set microprocessor as 16F84
INCLUDE <P16F84.INC>
; Setup processor configuration
__config _RC_OSC & _WDT_OFF & _PWRTE_ON
; label 2 symbols as memory addresses for counting loops
J equ 1F
K equ 1E
SETUP:
org 0 ;
BANKSEL TRISA ;
clrf TRISA ;
bcf STATUS , RP0 ;
bcf STATUS , RP1 ;
movlw 0x01 ;
movwf PORTB ;
bcf STATUS,C ;
ROTATE:
btfss PORTA,0 ;
goto RR
rlf PORTB,f ;
goto DELAY
RR: rrf PORTB,f ;
DeLAY:
movlw 0x32 ;
movwf J ;
jloop: movwf K ;
kloop: decfsz K,f ;
goto kloop
decfsz J,f ;
goto jloop
DIRECTION:
movlw 0x02 ;
xorwf PORTA,0;
goto ROTATE ;
end ;
Task 1
Rewrite the delay section of the program as a subroutine with annotations. Also show how it works by including a ‘printscreen’ of the whole program.
Also include a flowchart of the overall program and explain the subroutine section
State two advantages a subroutine might have over keeping the delay section within the main program
Explain with the aid of a diagram how the microprocessor stack operates.
Guidance: Use MPLAB to check that the code ‘builds’ correctly (this will check the syntax), print-screen a copy of code and build result into your answer and also email as ‘U19A2T2.asm’. There is no requirement to run or test the program.
Task 2
Rewrite the delay section of the program again using a built-in Timer0 function with annotations.
Also explain with aid of a diagram how the timer function counts the delay, including the role carried out by 3 key SFRs used in the program (different SFRs to those in task 1)
State two advantages an interrupt function might have over a subroutine
Guidance: Use MPLAB to check that the code ‘builds’ correctly (this will check the syntax), print-screen a copy of code and build result into your answer and also email as ‘U19A2T3.asm’. There is no requirement to run or test the program.
Task 3
From task 1 select MPLAB to build, run and test the program application.
Briefly comment on your test (Watch) results explaining the values stored in the SFR and variable registers.
Guidance: To test, you will need to change the delay loop from 0X032 to 0X002 in order to speed up the process in the simulator. Take a print-screen of the simulation running and use ‘View -> Watch’ to show evidence of the operation of key variables (symbols) and SFRs such as: J&K counters, the working, status and port registers; and also email as ‘U19A2T4.asm’.