Re: Timing Functionality on MPC555
"Eric" <[email protected]>
| Newsgroups | gmane.comp.hardware.motorola.microcontrollers |
|---|---|
| Message-ID | <[email protected]> |
Hi Randall, Jay, and Alex, Thank you all for taking some time to reply to my query - I had a lot to work with today. I think that using the decrementer would probably work fine - 32 bits is probably fine for most anything this would be used for. On the other hand, I get the impression that it will cause an interrupt, which isn't really useful for me (nor do I want to bother with masking it. The hardware watchpoints seems like a little bit of overkill. I also have the problem of not having any sort of scope that could measure the time difference on those signals. So, I'm using the TB register. I managed to figure out how to inline my assembly code with GNU so that I can read these. I also like this cause I could conceively take multiple timings at once (yes, I know that my code has it's own overhead, but it should be small amount, and I could estimate it if needed). I'm still trying to figure out how to verify the frequency of TMBCLK from system settings (observations suggest the TB is running at 2.5 ticks/microsecond), so if anyone wants to chime in I wouldn't mind (or else hopefully I'll figure it out Monday). Thanks again, everyone have a good weekend. -Eric Castle Emmeskay, Inc. --- In [email protected], "Randall Young" <ryoung@n...> wrote: > > 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/