Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

Latest threads

New Articles From Microcontroller Tips

Back
Top