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

Program, write a program assembly language for adding two 3*3 matrix

write a program assembly language for adding two 3*3 matrix

Shr-sar-logical instruction-microprocessor, SHR : Shift Logical Right: Thi...

SHR : Shift Logical Right: This instruction performs bit-wise right shifts on the operand word or byte that might be reside in  a memory location or a register, by the specified c

Right triangle, code, Assembly Language How to print strings in Right Tria...

code, Assembly Language How to print strings in Right Triangle form?

8086, to separate positive and negative numbers

to separate positive and negative numbers

8086, to separate positive and negative numbers

to separate positive and negative numbers

Code for reading flow & generating led output, Code for Reading Flow & Gene...

Code for Reading Flow & Generating LED Output The code starts with the scanning of the PORT 3, for reading the flow status to check for various flow conditions and compare to

Cobol, #I submitted my assignment this morning and it is still processing. ...

#I submitted my assignment this morning and it is still processing. How long does it take?

Assignment, Write an assembly program that adds the elements in the odd ind...

Write an assembly program that adds the elements in the odd indices of the following array. Use LOOP. What is the final value in the register?

Logical instruction-microprocessor, Logical Instruction : This type of...

Logical Instruction : This type of instructions is utilized for carrying out the bit by bit shift, basic logical operations or rotate. All of the condition code flags are affe

Computes the integral square root - assembly program, Computes the integral...

Computes the integral square root: Problem: Square Root:   For this problem you will write a short assembly program that computes the integral square root of an input numb

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