Skip to content

Instantly share code, notes, and snippets.

@mactkg
Created November 1, 2011 03:17
Show Gist options
  • Save mactkg/1329774 to your computer and use it in GitHub Desktop.
Save mactkg/1329774 to your computer and use it in GitHub Desktop.
line2.asm
; PIC test program
;
list p=16f84
;
; define config fuses
;
include "p16f84.inc"
__CONFIG _HS_OSC & _PWRTE_ON & _WDT_OFF
DELAYT EQU 0DH
;
LED0 EQU 00
LED1 EQU 01
M0 EQU 02
M1 EQU 03
SW0 EQU 00
SW1 EQU 01
S0 EQU 02
S1 EQU 03
S2 EQU 04
S3 EQU 05
;
TIMEF0 EQU 0CH
TIMEF1 EQU 0DH
TIMEF2 EQU 0EH
REG_A EQU 10H
REG_B EQU 11H
;
;
;********* Program Memory Programming ***********
;
ORG 00
GOTO INIT
ORG 04
GOTO INTR
ORG 10H
INIT
BSF STATUS,RP0 ;Select page 1
MOVLW 000H ;Set Input/Output
MOVWF PORTA ;SET PORT A
MOVWF INTCON
MOVLW 0ffh
MOVWF PORTB
BCF STATUS,RP0 ;SELECT PAGE 0
START
MOVLW 000H
MOVWF PORTA
MOVLW 0FFH ; Set 1
MOVWF REG_B
LIGHT
BSF PORTA,LED0
BCF PORTA,LED1
CALL DELAY
BCF PORTA,LED0
BSF PORTA,LED1
CALL DELAY
BTFSC REG_B,SW1
GOTO LIGHT
LOOP
BCF PORTA,M0 ;Moter0 OFF
BTFSC PORTB,S0 ;if(PORTB<S0>==1){
BSF PORTA,M0 ;Moter0 ON
BTFSC PORTB,S1 ;if(PORTB<S1>==1){
BSF PORTA,M0 ;Moter0 ON
BCF PORTA,M1 ;Moter0 OFF
BTFSC PORTB,S2 ;if(PORTB<S2>==1){
BSF PORTA,M1 ;Moter1 ON
BTFSC PORTB,S3 ;if(PORTB<S3>==1)}
BSF PORTA,M1 ;Moter1 ON
GOTO LOOP
;
DELAY
MOVLW DELAYT
MOVWF TIMEF0
LOOP0
CLRF TIMEF1
LOOP1
CLRF TIMEF2
LOOP2
MOVF PORTB,0
ANDWF REG_B,1
DECFSZ TIMEF2,1
GOTO LOOP2
DECFSZ TIMEF1,1
GOTO LOOP2
DECFSZ TIMEF0,1
GOTO LOOP2
RETURN
;
INTR
RETURN
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment