Write the Assembly Code for PIC16F84A microcontroller to read a switch connected to Bit 2 of PORTB. You will need to first set the pin to an input, then test whether the pin is 0 ( switch closed, if so go to existing program at label SWITCH If not the program is to continue: Add comments to each line to explain what the code does.
FILE: helloLed.asm
; AUTH: P.Oh
; DATE: 1.0 - 04/13/02 15:09
; DESC: 1.0 - Makes B0,B2,B4,B6 LO and B1,B3,B5,B7 HI
; NOTE: Tested on PIC16F84-04/P.
; Page numbers in code are in Easy Pic'n book
; REFs: Easy Pic'n p. 23 (Predko p. 173 is bogus?)
list p=16F84
radix hex
;-----------------------------------
; cpu equates (memory map)
myPortB equ 0x06 ; (p. 10 defines port address)
;---------------------------------
org 0x000
start movlw 0x00 ; load W with 0x00 make port B output (p. 45)
tris myPortB ; copy W tristate, port B outputs (p. 58)
movlw b'10101010' ; load W with bit pattern (p. 45)
movwf myPortB ; load myPortB with contents of W (p. 45)
circle goto circle ; done
end
;--------------------------------------
; at blast time, select:
; memory uprotected
; watchdog timer disabled
; standard crystal (4 MHz)
; power-up timer on
Get Answers For Free
Most questions answered within 1 hours.