Graham, Peter wrote: > > Hi all, > > This is my first time using the PIC controllers although I have had a > reasonable amount of experience using the HC11. > > I have a question about indirect addressing data in the program area. > > I have an external compass unit which has a lot of commands that I want > to access with the 16C63. I want to store these commands in the program > memory and then indirectly address these commands to be able to transmit > them to the compass unit. > > I have found app notes regarding this for higher level controllers but > not the 16C63. Is this possible or do I haveto load the commands into > the data area to indirectly address them with this controller. > > Peter G. > > --------------------------------------------------------------- > > Part 1.2 Type: application/ms-tnef > Encoding: base64 There is no direct memory access on the 16C series, you have to set up a jump table (and watch out for page boundaries) It goes something like this (from memory, no pun intended) main_prog movlw offset call table_rd .. table_rd addew PCL,f retlw 'm' retlw 'e' retlw 's' retlw 's' retlw 's' retlw 'g' retlw 'e' retlw 0x0d The problem arises if PCL+offset is >255 because you then have to add 1 to PCH too (page boundary). You may also need to implement some bounds checking, as this can in theory jump to anywhere on the same page. Consequently I usually put my tables on page 0 directly after the reset/interrupt vectors. That way I don't have to allocate a whole page for them, and I can see when they approach the page boundary. Hope this helps, Keith