HI JUST STARTED WITH PICS AND DID THIS AS A PROJECT AT COLLEGE WOULD NOW LIKE TO MOVE TO A BIGGER PIC BUT CANT GET IT WORK ANY IDEAS
[code]
LIST p=16F872 ;pic 16f84a is the target processor use mpaswin when using source code.
#include “p16F872.INC” ;include in header file
Org 4
goto start
_CONFIG H'3F30'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;memory set;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
intruptct1 set 12
direction set 13
alive set 14
position set 15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
goto isr
start bsf STATUS,RP0 ;select bank 1
clrf TRISB ;port b is out puts
movlw 05 ;divide by 2^(5+1) i.e. 64
movwf OPTION_REG ;see page 4 of session 5 hand out
bcf STATUS,RP0 ;back to bank 0
movlw -d’192’ ;initialise timer 0 to -192
movwf TMR0
movlw d’186’
movwf intruptct1 ;move 186 into mem location 12
movlw b’10100000’ ;enable interrupts from TMRO
movwf INTCON ;see page three of session 5 hand out
movlw b’00000001’ ;light up all leds
movwf position
movlw b’11111111’ ;light up all leds
movwf alive
bsf direction,0 ;set bit in ram
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;shoot led;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
testsw btfsc PORTA,0 ;test port a to see if switched
goto testsw ;goto above
movf PORTB,1
btfss STATUS,Z
goto clear
movf position,0
xorwf alive,1
goto testsw2
clear comf position,0 ;revearse position
andwf alive,1
testsw2 btfss PORTA,0 ;test port to see if switch relesed
goto testsw2
goto testsw ;goto first test switch
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;interupt service routine;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
isr movlw -d’192’ ;set timer back to -192
movwf TMR0
movlw b’10100000’ ;enable TMRO and reset TMRO flag
movwf INTCON
decfsz intruptct1 ;decrement interupt counter by 1
goto loop
movlw d'186'
movwf intruptct1 ;move 186 into mem location 12
btfsc direction,0 ;skip next if set
goto rotater ;goto rotate left
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rotate right;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
rlf position,1
movf position,0
andwf alive,0
movwf PORTB
btfss position,7 ;check if led on
goto loop
bsf direction,0 ;set bit 0 of ram address 13
goto loop
rotater rrf position,1
movf position,0
andwf alive,0
movwf PORTB
btfss position,0 ;check if led on
goto loop
bcf direction,0 ;set bit 0 of ram address 13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
loop retfie ;return to main program
end[/code]