Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;---------------------------------------------------
- ;FILE: EDbotTest.asm
- ;DESC: Design to test ED bot basic functionality
- ;DEVICE: PICmicro (PIC18F1220)
- ;---------------------------------------------------
- list p=18F1220
- radix hex
- config WDT=OFF, LVP=OFF, OSC=INTIO2
- #include p18F1220.inc ;This header file includes address and bit definitions for all SFR's
- #define dCount 0x80
- #define dCountInner 0x81
- org 0x000
- ;Initialize all I/O ports
- CLRF PORTA
- CLRF PORTB
- MOVLW 0x7F
- MOVWF ADCON1
- MOVLW 0x0D
- MOVWF TRISA
- MOVLW 0xC7
- MOVWF TRISB
- MOVLW 0x00
- ;Toggle Portb,5 direction, and delay.
- ;start by going forward for first delay cycle
- Main:
- BSF PORTB,4 ;Enable Right motor
- BSF PORTA,6 ;Forward Right
- BSF PORTB,3 ;Enable Left motor
- BSF PORTA,7 ;Forward Left
- MOVLW .2
- CALL Delay
- BSF PORTA,6 ;Forward Right
- CALL Loop1
- Loop1:
- BCF PORTA,7 ;Backward Left
- BSF PORTA,6 ;Forward Right
- MOVLW .2
- CALL Delay
- BSF PORTA,7 ;Forward Left
- BSF PORTA,6 ;Forward Right
- MOVLW .2
- CALL Delay
- CALL Loop2
- Loop2:
- BCF PORTA,7 ;Backward Left
- BSF PORTA,6 ;Forward Right
- MOVLW .1
- CALL Delay
- BSF PORTA,7 ;Forward Left
- BSF PORTA,6 ;Forward Right
- MOVLW .2
- CALL Delay
- CALL Loop1
- ;Delay function uses the Wreg value as the number of 1/10 of second delays
- Delay:
- MOVWF dCount
- DelayLoop:
- CALL DelayOnce
- DECF dCount
- BNZ DelayLoop
- RETURN
- DelayOnce:
- CLRF dCountInner ;Internal Delay loop
- DelayOnceLoop:
- NOP
- INCF dCountInner
- BNZ DelayOnceLoop
- RETURN
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement