Write a PIC 16F684 microcontroller assembly language program to control the Pres
ID: 3778268 • Letter: W
Question
Write a PIC 16F684 microcontroller assembly language program to control the President’s “nuclear football”. The program must monitor four push-button switches to determine which button is pressed to launch a nuclear missile to one of the four foreign countries. Once the push-button is pressed, turn on the LED for the country selected and launch a missile for that country. You must provide for “switch debouncing” in software.
Please give a written description of how your program operates as well as a diagram and a drawing or picture of what your device looks like. You may select any four foreign countries.
Explanation / Answer
Answer:
;Considering bank1
bank1
;Setting the RA port pins types
mov1w b'11111111'
;RA inputs ports
movwf TRISA
;Setting the RC port pins types
movlw b'11111110'
;including ALL the RC ports which excepts RC0 as output
movwf TRISC
;Go to bank0
bank0
MainLoop
;Reading the RA0 pins
btfss PORTA,RA0
;check the value of RA0 as'0' then move to the Button1_Is_Off
goto Button1IsOff
;sets the off button
Button1_Is_On
;sets the RC0 output
bsf PORTC,RC0
;going back to the main loop
goto MainLoop
;moves to the Button1IsOff
Button1IsOff
;clearing the RC0 output
bcf PORTC,RC0
;back to the mainLoop
goto MainLoop
;going back to bank1
;Considering bank1
bank1
;Setting the RA port pins types
mov1w b'11111111'
;RA inputs ports
movwf TRISA
;Setting the RC port pins types
movlw b'11111110'
;including ALL the RC ports which excepts RC1 as output
movwf TRISC
;Go to bank0
bank0
MainLoop
;Reading the RA1 pins
btfss PORTA,RA1
;check the value of RA1 as'0' then move to the Button2_Is_Off
goto Button2IsOff
;sets the off button
Button2_Is_On
;sets the RC1 output
bsf PORTC,RC1
;going back to the main loop
goto MainLoop
;moves to the Button2IsOff
Button2IsOff
;clearing the RC1 output
bcf PORTC,RC1
;back to the mainLoop
goto MainLoop
;going back to bank1
;Considering bank1
bank1
;Setting the RA port pins types
mov1w b'11111111'
;RA inputs ports
movwf TRISA
;Setting the RC port pins types
movlw b'11111110'
;including ALL the RC ports which excepts RC2 as output
movwf TRISC
;Go to bank0
bank0
MainLoop
;Reading the RA2 pins
btfss PORTA,RA2
;check the value of RA2 as'0' then move to the Button3_Is_Off
goto Button3IsOff
;sets the off button
Button3_Is_On
;sets the RC2 output
bsf PORTC,RC2
;going back to the main loop
goto MainLoop
;moves to the Button3IsOff
Button3IsOff
;clearing the RC2 output
bcf PORTC,RC2
;back to the mainLoop
goto MainLoop
;going back to bank1
;Considering bank1
bank1
;Setting the RA port pins types
mov1w b'11111111'
;RA inputs ports
movwf TRISA
;Setting the RC port pins types
movlw b'11111110'
;including ALL the RC ports which excepts RC3 as output
movwf TRISC
;Go to bank0
bank0
MainLoop
;Reading the RA3 pins
btfss PORTA,RA3
;check the value of RA3 as'0' then move to the Button4_Is_Off
goto Button4IsOff
;sets the off button
Button4_Is_On
;sets the RC3 output
bsf PORTC,RC3
;going back to the main loop
goto MainLoop
;moves to the Button4IsOff
Button4IsOff
;clearing the RC3 output
bcf PORTC,RC3
;back to the mainLoop
goto MainLoop
;going back to bank1
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.