PIC lights on, Assembly Language

Assignment Help:
errorlevel -302 ;prevents error code for this chipset
__config 0x373A ;chip config PIC spec page 146
processor 16F877A ;chipset

reset code 0x00
pagesel start ;Chooses pages from goto
nop ;does nothing
goto start

;**************************************************************************
code ;LABEL
start ;Label
clrf STATUS ;clear status from regester(Z is in status regester)
clrf PORTA ;clear port A
clrf PORTB ;clear port B
movlw 0x03 ;move literal into w
movwf PORTA ;move w into f

bsf STATUS, RP0 ;bit set f status, Regestry bank 0
movlw 0x07 ;move literal into w
movwf ADCON1
clrf TRISA ;clear register TriState regestry port A
clrf TRISB ;clear register TriState regestry port B
clrf TRISD ;clear register TriState regestry port D

CLRF STATUS
;*******************************************************************************
loop ;Start a Loop function
call LCD_update ;Calls LCD_Update function
call delay ;Calls delay function for time
goto loop ;Returns to loop


LCD_update_code code ;LAbEL
LCD_update ;LABEL

;IF CONTROL
sw1 btfsc PORTB, 1
goto display1
btfsc PORTB, 0
goto display2
display1
bcf PORTB, 0x01 ;turn Off LED 2
movlw 0xF9 ;Set number 1
movwf PORTD ;move w to f set PORTD
bsf PORTB, 0x00 ;turn On LED 1
goto finish_display

sw2 btfsc PORTB, 0
goto display2
btfsc PORTB, 1
goto display3
display2
bcf PORTB, 0x00 ;turn off LED
movlw 0x24 ;Set number 2
movwf PORTD
bsf PORTB, 0x01 ;turn on LED 2
goto finish_display


sw3 btfsc PORTB, 1
goto display3
btfsc PORTB, 0
goto display4
display3
bcf PORTB, 0x04 ;turn off LED 4
movlw 0x30 ;Set number 3
movwf PORTD
bsf PORTB, 0x02 ;turn on LED 3
goto finish_display


sw4 btfsc PORTB, 0
goto display3
btfsc PORTB, 1
goto finish_display
display4
bcf PORTB, 0x02 ;turn off LED 3
movlw 0x8D ;Set number 4
movwf PORTD
bsf PORTB, 0x04 ;turn on LED 4
goto finish_display

finish_display
RETURN

;*****************************************************************
;Variables for delay function

delay_udata udata ;LABEL
x res 2 ;x reserves 2 bytes

.delay code
delay
banksel x
clrf x
movlw 20
movwf x + 1
decfsz x, 1
goto $-1
decfsz x + 1, 1
goto $-3
return

end

Related Discussions:- PIC lights on

Data copy/transfer instructions-microprocessor, Data copy/transfer Instruct...

Data copy/transfer Instructions MOV: This data transfer instruction transfers data from one register or memory location to another register or memory location. The source can

Program help, Could I get an estimate on how much it would cost to write a ...

Could I get an estimate on how much it would cost to write a program in assembly language?

English, how we can take permission

how we can take permission

Computer organization, write a program using assembly language that print y...

write a program using assembly language that print your name

Fourth generation microprocessor, Fourth  Generation Microprocessor : T...

Fourth  Generation Microprocessor : The single chip 32-bit microprocessor was introduced in 1981 by Intel as iAPX 432. The other 4th generation  microprocessors  were;  Hewlett

Multiplication, how we can multiply two 8 bit number with rotation

how we can multiply two 8 bit number with rotation

Programming assembly language, Write an 8086 program to find out the number...

Write an 8086 program to find out the number of positive numbers and negative numbers from a given series of signed numbers include flow chart ..

Sub-arithmetic instruction-microprocessor, SUB: Subtract :- The subtract in...

SUB: Subtract :- The subtract instruction subtracts the source operand from destination operand and result is left in the destination operand. Source operand might be memory locati

Debug-microprocessor, Using DEBUG DEBUG.COM is a DOS efficacy that faci...

Using DEBUG DEBUG.COM is a DOS efficacy that facilitates the trouble-shooting and debugging of assembly language programs. In particular case of personal computers, all of th

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd