Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; test.asm Port J Output
- LIST P=18F97J60 ; directive to define processor
- #include <P18F97J60.INC> ; processor specific variable definition
- config XINST = OFF
- config FOSC = HS
- config WDT = OFF
- ORG 0x0000
- ResetV goto MAIN ; Skip over interrupt vectors
- ORG 0x0008
- HPISR
- retfie
- ORG 0x0018
- LPISR
- retfie
- ORG 0x0100 ; Suggest starting address for codes
- MAIN
- movlw 0x00 ;initilise PortD (motor) to output
- movwf TRISD,0
- movlw B'00000000' ;clear PortD
- movwf LATD,0
- movlw 0x00 ;initialise PortJ (LED) to output
- movwf TRISJ,0
- movlw B'00000001' ;initialise
- movwf LATJ,0
- movlw 0xFF
- movwf TRISB,0
- movlw 0x00
- movwf TRISC,0
- movlw 0x00
- movwf TRIS
- movlw 0x3d
- movwf PR2,0
- movlw B'01111111'
- movwf T2CON
- movlw 0x00
- movwf 0x05
- movlw 0x00
- movwf 0x04
- step1 movlw 0x00
- movwf PORTC,0
- btfss PORTB,1,0
- goto john
- movlw 0x01
- movwf PORTD,0
- btfss PIR1,1,0
- goto step1
- bcf PIR1,1,0
- step2 btfss PORTB,1,0
- goto john
- movlw 0x02
- movwf PORTD,0
- btfss PIR1,1,0
- goto step2
- bcf PIR1,1,0
- step3 btfss PORTB,1,0
- goto john
- movlw 0x04
- movwf PORTD,0
- btfss PIR1,1,0
- goto step3
- bcf PIR1,1,0
- step4 btfss PORTB,1,0
- goto john
- movlw 0x08
- movwf PORTD,0
- btfss PIR1,1,0
- goto step4
- bcf PIR1,1,0
- incf 0x05,1,0
- movlw 0x64
- cpfsgt 0x05,0
- bra step1
- incf LATJ,1,0
- movlw 0x00
- movwf 0x05
- movlw 0x00
- movwf 0x04
- bra step1
- ; Trap CPU here
- john movlw 0xFF
- movwf PORTC,0
- movlw 0x00
- movwf PORTD,0
- btfss PORTB,0,0
- goto step1
- goto john
- END ; No code beyond this line, absolutely.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement