Searching \ for 'PCL Updates' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=pcl+updates
Search entire site for: 'PCL Updates'.

Truncated match.
PICList Thread
'PCL Updates'
1999\10\17@222549 by Thomas Brandon

flavicon
picon face
I am looking at doing jumps by modifying PCL, the application is very
deterministic so keeping time is critical. If I have code such as the
following (Yes, I know it doesn't do anything useful):

EQU jump_cond ...

ORG 0x10
   MOVF jump_cond (0x10)
   ADDWF PCL (0x11)
   ADDLW 0x00  (0x12)
   ADDLW 0x01  (0x13)
   ADDLW 0x02  (0x14)

Now what is the timing of the jump. The MChip docs don't mention any
delays\problems whereas in other such places they do. What happens if
jump_cond = 0x00. Would the flow be:
PC        Executing        Fetching
0x10      0x10              0x11
0x11      0x11              0x12 (adds 0 to PC)
0x12      0x12              0x13
0x13      0x13              0x14

Now, what if jump_cond = 0x01, is the flow:
PC        Executing        Fetching
0x10      0x10              0x11
0x11      0x11              0x12 (adds 1 to PC)
0x13      0x12              0x14
0x14      0x14              0x15

Or does it somehow manage to fetch the instruction of the updated PCL in the
same inst. it is updated?

Thanks,
Tom.

1999\10\17@223840 by Tony Nixon

flavicon
picon face
Thomas Brandon wrote:
ORG 0x10
   MOVF jump_cond (0x10)
   ADDWF PCL (0x11)
   ADDLW 0x01  (0x12)
   ADDLW 0x01  (0x13)
   ADDLW 0x02  (0x14)

In all cases depending on the addlw value

addlw 1

PC        Executing        Fetching
0x10      0x10              0x11
0x11      0x11              0x12 (adds 1 to PC) <<< adds 1 to PCL
Discard   0x12              0x13 (this is why addwf PCL takes 2 cycles)
0x13      0x13              0x14
0x14      0x14              0x15

addlw 2

PC        Executing        Fetching
0x10      0x10              0x11
0x11      0x11              0x12
Discard   0x12              0x14
0x14      0x14              0x15
0x15      0x15              0x16

--
Best regards

Tony

http://www.picnpoke.com
Email spam_OUTsalesTakeThisOuTspampicnpoke.com

1999\10\18@000537 by Mike Keitz

picon face
On Mon, 18 Oct 1999 12:29:03 +1000 Thomas Brandon <.....tomKILLspamspam@spam@PSY.UNSW.EDU.AU>
writes:

> Now what is the timing of the jump. The MChip docs don't mention any
> delays\problems whereas in other such places they do. What happens
> if
> jump_cond = 0x00.

Adding to PCL always takes 2 cycles, even if zero is added.  Any time PCL
is written a PIC always dumps the pre-fetched instruction and reads a new
one from the new PC.  It isn't "smart" enough to know if the new PC is
the same as the old one.  Similarly a call or goto also always takes 2
cycles, even if the destination is the next instruction anyway.

___________________________________________________________________
Get the Internet just the way you want it.
Free software, free e-mail, and free Internet access for a month!
Try Juno Web: dl.http://www.juno.com/dynoget/tagj.

1999\10\18@005211 by paulb

flavicon
face
Thomas Brandon wrote:

> Now what is the timing of the jump.  The MChip docs don't mention any
> delays\ problems whereas in other such places they do.

 I think they do somewhere mention operations affecting PCL.  It takes
two cycles.

> What happens if jump_cond = 0x00.

 I think W is added to the current program counter.  The current PC is
however the one from which the subsequent instruction is presently being
fetched so irrespective of whether the resultant address is the same,
the maths has been performed and the PC re-written, the fetch is
invalidated and a new fetch is performed on the next cycle.

 This is where the extra cycle in all PC-altering instructions occurs.

 Consequently, the first table element corresponds to the zero index.
--
 Cheers,
       Paul B.

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...