Question: Using assembly code in MPLAB for a microcontroller PIC18F45K50 build a counter from 00 to 59 using two seven segment displays Complete the code in
Using assembly code in MPLAB for a microcontroller PIC18F45K50
build a counter from 00 to 59 using two seven segment displays
Complete the code in the image below for a counter to count from 00 to 59 then reset back to 00
org 0 GOTO start ; Jump to entry spec'd by w. ;0, 1, 2, 3 ;4,5,6 Lookup ADDWF pel RETLW d'63' RETLW d'6' RETLW d'91 RETLW d'79' RETLW d'102 RETLW d'109 RETLW d'125 RETLW d'7' RETLW d'127' RETLW d'103' RETLW d'119 RETLW d'124' RETLW d'57' RETLW d'94' RETLW d'121 RETLW d'113' ;7,8,9 ;A,B,C ;D,E,F start MOVLW d'O' ; All outputs for LEDs MOVWF TRISD MOVWF PORTD All LEDs off to begin. CLRF count ; Start count at 0. start_loop MOVF count,w ; Put number to look up into w. ANDLW b'00001111' ; Strip off high bits. CALL Lookup ; Call the table. MOVWF PORTD ; Write pattern in w to LEDs. start_wait DECFSZ temp ; Short delay GOTO start_wait DECFSZ temp2 GOTO start_wait INCF count ; count = count + 1 GOTO start_loop ; Do it again. end org 0 GOTO start ; Jump to entry spec'd by w. ;0, 1, 2, 3 ;4,5,6 Lookup ADDWF pel RETLW d'63' RETLW d'6' RETLW d'91 RETLW d'79' RETLW d'102 RETLW d'109 RETLW d'125 RETLW d'7' RETLW d'127' RETLW d'103' RETLW d'119 RETLW d'124' RETLW d'57' RETLW d'94' RETLW d'121 RETLW d'113' ;7,8,9 ;A,B,C ;D,E,F start MOVLW d'O' ; All outputs for LEDs MOVWF TRISD MOVWF PORTD All LEDs off to begin. CLRF count ; Start count at 0. start_loop MOVF count,w ; Put number to look up into w. ANDLW b'00001111' ; Strip off high bits. CALL Lookup ; Call the table. MOVWF PORTD ; Write pattern in w to LEDs. start_wait DECFSZ temp ; Short delay GOTO start_wait DECFSZ temp2 GOTO start_wait INCF count ; count = count + 1 GOTO start_loop ; Do it again. end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
