Confused over table 256 byte page boundry

Status
Not open for further replies.
Mike - after a few hours of the debugger the problem/s been found!!

1) I needed to remove the call as you suggested
2) In my original code I had

Code:
Keys

	movlw HIGH Key_Table
	movwf PCLATH
	movlw index

Key_Table  ADDWF   PCL , f
            	RETLW   0x31	;1
                ......

This should have rather been:
Code:
	movlw HIGH Key_Table
	movwf PCLATH
	movf index, w

I was moving the memory location 'index' into W, rather than the contents of index

3) And last of all, the killer...After I call the table my program proceeds and at a later stage calls a another table within the first 256 bytes so I used the normal "ADDWF PCL , f" with none of the other HIGH/PCLATH stuff.

The problem there being PCLATH already contained a value set from the Key_Table. When I now called another table it fell over. I just needed to clear the PCLATH register and its all working 100%

I suppose the better way to do this would be to save the PCLATH and then restore it instead of just clearing it?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…