;Author : LEBOHANG MAPHOTHOANE
;PROGRAM FUNCTION:turning motor
list P=16F877a
include "P16F877a.inc"
__config 0x3D18
;errorlevel -302, -207;suppress message 302 from the list
;Declarations:
CBLOCK 20h ; Temporary storage
pos
dc1
dc2
delay
ENDC
org 0x0000
goto Start
;Program Start:
Start
call Init ;sets the values of ADCON0 and ADCON1
;initialize porta
Main
;clockwise
movlw b'0001'
movwf PORTB
call wait
clrf PORTB
movlw b'0100'
movwf PORTB
call wait
clrf PORTB
movlw b'0010'
movwf PORTB
call wait
clrf PORTB
movlw b'1000'
movwf PORTB
call wait
clrf PORTB
goto Main
wait movlw 4 ; Outer loop iteration count
movwf dc1
dl1 clrf dc2 ; Initialize inner loop
dl2 nop
nop
decfsz dc2,F
goto dl2
decfsz dc1,F
goto dl1
return
;Subroutines:
Init
clrw ; Zero.
movwf PORTB ; Ensure PORTB is zero before we enable it.
bsf STATUS,RP0 ; Select Bank 1
movlw 0xF0 ; Set port B bits 0-3 as outputs
movwf TRISB ; Set TRISB register.
bcf STATUS,RP0 ; Select Bank 0
return
END