Question 4 (35 marks)
A program written in galaxy dialect targeted ce PIC18F4550 microcontroller is listed as below:
;*****Fixed up the Trues****
STATUS equ 03h ;Address of the STATUS record
COUNT1 equ 08h ;Primitive contrary ce our relapse loops
COUNT2 equ 09h ;Second contrary ce our relapse loops
;****Fixed up the mien****
bsf STATUS,5 ;Switch to Bank 1
movlw 00h ;Fixed the Mien B buttons
movwf TRISB ;to output.
bcf STATUS,5 ;Switch tail to Bank 0
;****Rotate the LED on****
Start movlw 02h ;Rotate the LED on by primitive putting it
movwf PORTB ;into the w record and then on the mien
;****Set-out of the relapse loop 1****
Loop1 decfsz COUNT1,1 ;Subtrstrike 1 from 255
goto Loop1 ;If COUNT is naught, convey on.
decfsz COUNT2,1 ;Subtrstrike 1 from 255
goto Loop1 ;Go tail to the fixed-out of Loop 1.
;****Relapse refined, now rotate the LED impromptu****
movlw 00h ;Rotate the LED impromptu by primitive putting
movwf PORTB ;it into the w record and then on the mien
;****Add another relapse****
Loop2 decfsz COUNT1,1
;****Now go tail to the fixed-out of the program
goto Fixed-out ;go tail to Fixed-out and rotate LED on again
;****End of the program****
END ; End of program
Given that the crystal abundance is 1MHz and each adbadness takes 4 cycles to execute:
(a) Identify the output button used ce this program. [2 marks]
(b) Draw the circumference selfsame to this program. [5 marks]
(c) Determine the calculate of counting manufactured by Loop1 and Loop2. [5 marks]
(d) Explain why span relapse loops, Loop1 and Loop2 are deficiencyed ce the program aloft. [5 marks]
(e) Explain the drawtail of using span relapse loops ce the program aloft. [3 marks]
(f) Rewrite the aloft program using barely individual relapse loop (Loop1). [15 marks]
Few points about PIC18F4550 :
PIC18F4550 is an 8-bit microcontroller of PIC18 sequenceage.
PIC18F sequenceage is inveterate on 16-bit adbadness fixed fabric.
PIC18F4550 halts of 32 KB glitter recollection, 2 KB SRAM and 256 Bytes EEPROM.
a)The output button used ce this program is 40, span rows of button each of 20 on twain the plane. It instrument the input button used is 20 buttons and the calculate of output button is 20 buttons. PIC Microcontroller is used halting of 5 I/O miens (PORTA, PORTB, PORTC, PORTD and PORTE).here to-boot it is halt of 5 input/output miens.
In this program PORTB is used. PORTB entertain 8 buttons to receive/transmit 8-bit I/O facts. The retaining miens entertain opposed calculates of buttons ce I/O facts communications.In PORTB a logic individual (1) in the TRISB record configures the divert mien button as input and badness versa. Six buttons on this mien can strike as analog inputs (AN).
c)The calculate of counting manufactured on loop1 is 255 .
What we entertain dindividual is primitive fixed up our true COUNT to 255. The contiguous sequence puts a label, determined LABEL contiguous to our decfsz advice. The decfsz COUNT,1 decreases the appraise of COUNT by 1, and stores the effect tail into COUNT. It to-boot checks to experience if COUNT has a appraise of naught. If it doesn’t, it then causes the program to provoke to the contiguous sequence. Here we entertain a ‘goto’ proposition which sends us tail to our decfsz advice. If the appraise of COUNT does similar naught, then the decfsz adbadness causes our program to bounce span fixs ceward, and goes to where We entertain said ‘Convey on here’. So, as you can experience, we entertain caused the program to remain in individual fix ce a predetermined interval anteriorly conveying on. This is determined a relapse loop. If we deficiency a larger relapse, we can supervene individual loop by another. The over loops, the longer the relapse. We are going to deficiency at lowest span, if we lack to experience the LED glitter.