I see that you have the same problem that I had. I've resolved that
after long experiments with MPLAB-SIM because I didn't understood the data
sheet.You have to check out the AN556 on the Microchip's site.You can put
a table any where you want in prog.memory but you have to preset the PCLATH
before the call table is executed.
example.
PC &n
bsp;
opcode
----------------------------
xxx main -
&nbs
p;
-
xxx &
nbsp;
movlw H'02'
xxx &
nbsp;
movwf PCLATH
xxx &
nbsp;
call Table
&nbs
p;
-
&nbs
p;
-
246 Table addwf PCL
247
retlw ....
248
retlw ....
249
............
2xx
- // -
You have to check, on which page in the prog.memory is the Table. In this example the Table begin in the H'246' so PCLATH has to be preloaded with H'02'. Be carefull that the Table doesn't cross a page boundary. If it does , you can check out AN556 example 6.The best way to check where the Table begin and stop is to assembly the program and check in the program.lst file.
good luck, Valter
Stuart Allen wrote:
Hello,I use the modification of PCL extensively to implement switch statements.
And I am fully aware of the consideration that must be given to PCLATH.However, if I modify PCL when in the top 100H bytes of a 16C84 processor, it
doesn't work. The processor jumps off to somewhere completely different to
where I want it to go.This also happens in the DOS simulator! I haven't done very much
investigation into this problem, I just keep all my jump tables in the first
page of ROM and that avoids it.I don't know exactly where in RAM this problem starts occuring, but it's
near the top on ROM.Please note that in this case, I do NOT modify PCLATH, because I know that
the table doesn't cross a 100H boundary.Has anybody else noticed this? Have I mis-understood/missed something?
More investigation with a simulator or emulator would be useful I know.
Thanks for any insight,
Stuart.