Sun May 19, 2013 11:14 pm
TITLE "MoTOR SPEED CONTROL"
list p=16f877
include <p16f877.inc>
BANK0 macro
bcf STATUS,RP0
bcf STATUS,RP1
endm
BANK1 macro
bsf STATUS,RP0
bcf STATUS,RP1
endm
BANK2 macro
bcf STATUS,RP0
bsf STATUS,RP1
endm
BANK3 macrc
bsf STATUS,RP0
bsf STATUS,RP1
endm
OFF EQU 0;MOTOR oFF
DELAY_TIME EQU 0x20
;
ORG 0
NOP
GOTO START
; MAIN ROUTINE
ORG 0x20
START CALL INITP ;INITIALISE PoRT
MOVLW 1 ;SET MOTOR CW
MOVWF PORTE ;AND OUTPUT
MOVLW 0 ;SET MOToR CW
MOVWF PORTA ;AND OUTPUT
CALL START_DELAY ;WAIT
AGAIN MOVLW 0FF ;SET MOToR oFF
MOVWF PORTE ;AND oUTPUT
MOVWF PORTA
CALL OFF_DELAY ;WAIT
MOVLW 1 ;SET MOToR CW
MOVWF PORTE ;AND OUTPUT
MOVLW 0 ;SET MOToR cW
MOVWF PORTA ;AND oUTPUT
CALL ON_DELAY ;WAIT
GOTO AGAIN ;DO FOR EvER
;*******
; ON DELAy
ON_DELAY
MOVLW 0x80 ;SET DELAy TIME
MOVWF DELAY_TIME
WAIT1 INCFSZ DELAY_TIME ;OoUNT DoWN
GOTO WAIT1
RETURN
; OFF DELAY ROUTIN
OFF_DELAY
MOVLW 0x8O ;5ET DELAY TIME
MOVWF DELAY_TIME
WAIT2 INCFSZ DELAY_TIME ;COUNT DOWN
GOTO WAIT2
RETURN
; START DELAY ROUTIN
START_DELAY
MOVLW 0x80 ;SET DELAy TIME
MOVWF DELAY_TIME
WAIT3 INCFSZ DELAY_TIME ;CoUNT DoWN
GOTO WAIT3
RETURN
; PORT INITIALISATION
INITP BANK1; SET TO BANK 1
MOVLW 06 ; MAKE PORT A DIGITAL
MOVWF ADCON1
BCF PORTA,5; MAKE BIT 5 OUTPUT
CLRF TRISE ; SET PORT E TO OUTPUT
BANK0 ; BACK TO BANK 0
RETURN
END
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.