RE: Timing Functionality on MPC555

"Randall Young" <[email protected]>
Newsgroups gmane.comp.hardware.motorola.microcontrollers
Message-ID <[email protected]>
> I want to measure how long certain functions are taking in my code, so
> I want a way to track time rather accurately (precision on the order
> of micro-seconds, hopefully).  I was wondering what I should be using
> just to get two values - a starting time, and an ending time.  I was
> hoping to read directly from the real-time clock, but that seems to
> give garbage as output.
>
> Anyone know what I should be looking at?

I'd suggest using the time base registers.  Takes (2) 32 bit reads to get
the whole thing, so the code goes something like :

    mftbu   r5          # load upper word of time base
    mftb    r4          # load lower word of time base
    mftbu   r3          # re-read upper word
    cmpw    r3,r5       # check that upper word didnt change
    beq     got_time    # If not, branch
    mftb    r4          # It changed, have to get new LSW to match
got_time:               # (result in r3:r4)

As I recall, the resolution depends on your CPU clock and some prescaler
options on the MPC555 ... should be microseconds or better.  You'll also
have to enable the time base, which as I recall also enables the decrementer
and it's exception.

Randall Young
Senior Software Engineer
NavCom Technology, Inc.
A John Deere Company



-----------------------------------------------------------
To learn more about Freescale Microcontrollers, please visit
http://www.freescale.com/mcu


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/MPC500/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.