Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(A)Write a single assembly code for PIC18F458 microcontroller which is sequentia

ID: 3349226 • Letter: #

Question

(A)Write a single assembly code for PIC18F458 microcontroller which is sequentially turn on/off 8 bit LEDs, all LEDs are connected to port B of PIC18F458. (Abet outcome C and K) (B) Show the results in Proteus software Project Description: Case1: Sequentially turn on LEDS from left to right (from LSB to MSB) Hint :00000001, 00000010 10000000] Case 2: Sequentially turn on LEDS from right to left (from MSB to LSB) Hint:1000000,010 Case 3: Turn on one LED from left and one LED form right side (one by one) Case 4: Turn on/off 8 LEDS respectively. Case 5: This program will continue forever.

Explanation / Answer

To set Input/Output type on PORTB we have to use TRIS register.

If TRIS register has bit '1' it will be considered as INPUT pin

If TRIS register has bit '0' it will be considered as OUTPUT pin.

COUNT1 equ 08h

COUNT2 equ 01h

start movlw 00h // Set all PORTB pins as output i.e, 0b00000000

movwf TRISB

main GOTO case1

GOTO case2

GOTO case3

GOTO case4

GOTO main

case1 movlw 01h

movwf PORTB

call delay

movlw 02h

movwf PORTB

call delay

movlw 04h

movwf PORTB

call delay

movlw 08h

movwf PORTB

call delay

movlw 10h

movwf PORTB

call delay

movlw 20h

movwf PORTB

call delay

movlw 40h

movwf PORTB

call delay

movlw 80h

movwf PORTB

call delay

case2 movlw 80h

movwf PORTB

call delay

movlw 40h

movwf PORTB

call delay

movlw 20h

movwf PORTB

call delay

movlw 10h

movwf PORTB

call delay

movlw 08h

movwf PORTB

call delay

movlw 04h

movwf PORTB

call delay

movlw 02h

movwf PORTB

call delay

movlw 01h

movwf PORTB

call delay

case3 movlw 81h

movwf PORTB

call delay

movlw C3h

movwf PORTB

call delay

movlw E7h

movwf PORTB

call delay

movlw FFh

movwf PORTB

call delay

case4 movlw 00h

movwf PORTB

call delay

delay

loop1 DECFSZ COUNT1, 1

goto loop1