Countdown program using assembly language for pic

July 26, 2014
; this program is countdown timer using
; assembly language for pic microcontroller
; upon setting the chosen number
; it will count down automatically 

; portB3 for tens switch
; portB2 for ones switch
; portB1 for reset switch
; portB0 for start/pause switch
; portC for the 7 segment display of tens
; portD for the 7 segment display of ones
; pic16f877a

bsf status,5
movlw 1111b
movwf trisb
clrf trisc
clrf trisd
bcf status,5

movlw 0x32
movwf 0x31

again btfsc portb,0
goto again

reset movlw 9
movwf 0x20
movwf 0x21
movwf 0x24
movlw 1101111b
movwf portc
movwf portd
bet btfsc portb,1
goto reset
btfsc portb,2
goto ones
btfsc portb,3
goto tens
btfsc portb,0
goto delay
goto bet
goes decf 0x20,1
movf 0x20,0
movwf 0x24
sublw 0xff
btfsc status,z
goto aff
call read
poc movwf portd
goto bet
read movf 0x24,0
sublw 1
btfsc status,z
goto a1
movf 0x24,0
sublw 2
btfsc status,z
goto a2
movf 0x24,0
sublw 3
btfsc status,z
goto a3
movf 0x24,0
sublw 4
btfsc status,z
goto a4
movf 0x24,0
sublw 5
btfsc status,z
goto a5
movf 0x24,0
sublw 6
btfsc status,z
goto a6
movf 0x24,0
sublw 7
btfsc status,z
goto a7
movf 0x24,0
sublw 8
btfsc status,z
goto a8
movf 0x24,0
sublw 9
btfsc status,z
goto a9
movf 0x24,0
sublw 0
btfsc status,z
goto a0
aff movlw 9
movwf 0x20
decf 0x21,1
movf 0x21,0
movwf 0x24
sublw 0xff
btfsc status,z
goto again
call read
movwf portc
movlw 1101111b
goto poc
a1 movlw 110b
return
a2 movlw 1011011b
return
a3 movlw 1001111b
return
a4 movlw 1100110b
return
a5 movlw 1101101b
return
a6 movlw 1111101b
return
a7 movlw 111b
return
a8 movlw 1111111b
return
a9 movlw 1101111b
return
a0 movlw 111111b
return
delay movlw 0x03
movwf 0x30
wee decfsz 0x30,1
goto wee
decfsz 0x31,1
goto wee
movlw 0x32
movwf 0x31
goto goes
ones btfsc portb,2
goto ones
decf 0x20,1
movf 0x20,0
movwf 0x24
sublw 0xff
btfsc status,z
call clro
call read
movwf portd
goto bet
tens btfsc portb,3
goto tens
decf 0x21,1
movf 0x21,0
movwf 0x24
sublw 0xff
btfsc status,z
call clrt
call read
movwf portc
goto bet
clro movlw 9
movwf 0x20
movwf 0x24
return
clrt movlw 9
movwf 0x21
movwf 0x24
return
end
 

USING RRF AND RLF

July 3, 2014
; using RLF and RRF
; RRF = rotate bit to the right
; RLF = rotate bit to the left
; simulate using picsimulator ide 8xLED board
; mcu = pic16f84a

; this is a running lights

; set up pins
    bsf status,5
    movlw 0x00
    movwf trisa
    bcf status,5

    movlw 0x32
    movwf 0x21    ; store decimal value 50 to 0x21

;main program
main    movlw 0x01
    movwf porta
    call delay

    rlf porta,1    ; 1 is the destination register (porta)
                     ; for the result of operation
    call delay

    rlf ...
Continue reading...
 

USING BTFSS AND BTFSC

July 1, 2014

; program using BTFSS and BTFSC

; BTFSS = Check status of the specified bit number,

                ;skip one (1) instruction if set as high (on state)

; BTFSC = Check status of the specified bit number,

                ;skip one (1) instruction if set as low (off state)

; mcu = pic16f84A

; simulate using picsimulatoride

 

; Set up the pins of the microcontroller

BSF STATUS,5          ; bit set on pin 5 of status register

                                            ; from bank0 to bank1...


Continue reading...
 

Sample Assembly Programming

July 1, 2014

;  - Sample programs using assembly language in PIC -

; mcu = pic16f84A

; simulate using picsimulatoride

; Set up the pins of the microcontroller

        BSF STATUS,5      ; BIT SET ON PIN 5 OF STATUS REGISTER

                                    ; FROM BANK0 TO BANK1 ON REGISTER FILE MAP

        MOVLW 0X00        ; MOVE LITERAL VALUE 0000 0000

        MOVWF TRISA     ; SET ALL PORTA PINS AS OUTPUT

        BCF STATUS,5      ; BIT CLEAR ON PIN 5 OF STATUS REGISTER

                  ...


Continue reading...
 

How Microprocessor Works - Simple Explanation

August 26, 2010

Continue reading...
 

How Binary Code Works

August 26, 2010

Continue reading...
 

Blog Archive

 
Make a Free Website with Yola.