Were have i gone wrong

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]

M1DGQ

I am no great expert in this as I am only learning myself at the moment - but a few observations.

Org 4 goto start _CONFIG H'3F30'

This section looks wrong to me. The code should start at 0x000 and the ISR should be at 0x004. The main code should also start with the code word, therefore the start should look something like this:

[code]; -----------------------------------------------------------------------
;
#include <p16f872.inc>

; -----------------------------------------------------------------------
; Configuration bits: adapt to your setup and needs
__CONFIG _RC_OSC & _WDT_ON & _PWRTE_OFF & _BODEN_ON & _LVP_ON & _CPD_OFF & _WRT_ENABLE_ON & _DEBUG_OFF & _CP_OFF

; -----------------------------------------------------------------------
; Variables declaration
INT_VAR UDATA_SHR
w_saved RES 1 ; variable used for context saving
status_saved RES 1 ; variable used for context saving
pclath_saved RES 1 ; variable used for context saving

; -----------------------------------------------------------------------
; reset vector
STARTUP CODE 0x000
nop ; needed for ICD2 debugging
movlw high start ; load upper byte of ‘start’ label
movwf PCLATH ; initialize PCLATH
goto start ; go to start of main code

; interrupt vector
INT_VECTOR CODE 0x004
goto interrupt ; go to start of interrupt code

; relocatable code
PROG CODE
interrupt
movwf w_saved ; save context
swapf STATUS,w
movwf status_saved
movf PCLATH,w ; only required if using more than first page
movwf pclath_saved
clrf PCLATH
; << insert interrupt code >>
movf pclath_saved,w ; restore context
movwf PCLATH
swapf status_saved,w
movwf STATUS
swapf w_saved,f
swapf w_saved,w
retfie

start
; << insert main code >>
goto $ ; loop forever

END[/code]

It may also help if you could give some idea what the code is supposed to do, for example:

Why is this commented as a divide by 64?

Hope this is of some halp and please come back to me if you think I can help more.

Best wishes.

thanks for the help to give you some back ground .

8 leds doing a night rider effect when a button is pressed an led goes out if you manage to do this with all leds game over. if you dont you can re light the leds .

basicly its a reaction game trying to turn off all the leds with out turning any back on .

dont worry about the comments this is the throw back from copying collage test programs and not tiding up afterwards.

may be you could help with part two if i can get this working .???

Peter

I would be more than happy to help in any way that I can.
I hope the above was of some help but please let me know if I can help you further. :smiley:

Best regards,

Rupert