Issues with PIC16F877A and using the FSR address...

Status
Not open for further replies.

si2030

Member
Hi All

Ok again I am confused as I have my program working with FSR in one place and not in another. I have a video of it not working using the debugger..

**broken link removed**

Ok so I have the piece of code in the MAIN program and as you can see W gets a 5 from INDF however when I have it as part of a call routine from the interrupt routine W is not updated..

the code is this:

Code:
MOVLW	H'07'
MOVWF	POS_1
MOVLW	H'27'
MOVWF	FSR
movf	INDF,W

Basically the movf INDF,W wont accept the value FSR is pointing too and I have no idea why?

Simon
 

Attachments

  • FUNCTION_GEN_MAIN_P&.asm
    20.4 KB · Views: 139

hi si,
I need the two include files.
 
hi Simon,
The ISR is incorrect, look at this edited version.

Code:
;=============================================================================
;THIS IS THE INTERUPT ROUTINE.
;=============================================================================
INTERRUPT	org	ISR_V		;INTERRUPT VECTOR LOCATION.

		movwf     _W
		swapf     STATUS,W
		movwf     _STATUS

	movf	PCLATH,w	  ; move pclath register into w register
	movwf	pclath_temp	  ; save off contents of PCLATH register

		bcf       STATUS,RP0;SELECT BANK 0.
          	
		CALL WAIT_15MS
		
		movlw   B'11110000'	;CHECK FOR KEY DOWN.
		movwF   TEMP  
		movf    PORTB,W
		subwf   TEMP,F
		btfsc	STATUS, Z
		goto    DONE		;ALL KEYS UP SO RETURN.
		;call	HZ_LABEL	;DISPLAY KEYCODE ON RD0,1,2 AND 3.
		call	SHIFT_KEYS
		;call    GETKEY		;KEY PRESSED NOW IN W (0 - 15).
		;movwf   LAST_KEY
			
		;call	SAVE_KEY		
		;call 	FREQ_LABEL
				
DONE
		clrf    PORTB		;CLEAR PORT B.
		clrf    PORTD		;CLEAR PORT D.
		movf    PORTB,F

 	bcf     INTCON,RBIF;CLEAR Port B interrupt FLAG

	movf	pclath_temp,w	  ; retrieve copy of PCLATH register
	movwf	PCLATH		  ; restore pre-isr PCLATH register contents

	movf    _STATUS,W     ; retrieve copy of STATUS register	
		;;;swapf   STATUS,W	;RESTORE SAVED REGISTERS.
		movwf   STATUS
		swapf   _W,F
		swapf   _W,W	
		retfie
 
Hi Eric

Sorry about that.. should have included them

I am doing that now and then adding the additional items and checking them

Thanks

Simon
 

Attachments

  • LCD and KEYPAD ROU&#84.zip
    3.8 KB · Views: 128
Hey that worked!! Wondering if you could tell me why it did....

Also, with regard to my previous question I just changed the interrupt so as to include setting FLAGS bit 0 to 1 and then testing in the LOOP section... again the btfsc didnt work... I have included the ASM file just updated to include the FLAG option...

Thanks for looking at this...

Simon
 

Attachments

  • FUNCTION_GEN_MAIN_P&.asm
    20.4 KB · Views: 130
I think I have fixed this as well...

I put a NOP before the btfss (I changed the btfsc to btfss) and it now works... I will now change it so it works like this

Thanks

Si
 

hi,

;;movf _STATUS,W ; retrieve copy of STATUS register ; this line was missing
This line : ;;;swapf STATUS,W ;RESTORE SAVED REGISTERS. ; ?????

Also you should save/restore PCLATH
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…