Stopwatch.h for MOD54415?

Discussion to talk about software related topics only.
barttech
Posts: 135
Joined: Fri Feb 20, 2009 12:59 pm

Stopwatch.h for MOD54415?

Post by barttech »

I have the Stopwatch code from lgitlitz but it needs a
NB_CPU_CLK
value defined.

#if (defined MCF5282 || defined MCF5213)
#define NB_CPU_CLK ( 66355200 )
#elif defined MCF5272
#define NB_CPU_CLK (62500000 / 4096)
#elif defined MCF5208
#define NB_CPU_CLK ( 83335000 )
#elif defined MCF53017
#define NB_CPU_CLK ( 80000000 )
#elif (defined MCF5234 || defined MCF5270)
#define NB_CPU_CLK ( 73728000 )
#else
#error PROCESSOR NOT DEFINED
#endif

What is the right value for the MOD54415?
Thanks!
User avatar
pbreed
Posts: 1084
Joined: Thu Apr 24, 2008 3:58 pm

Re: Stopwatch.h for MOD54415?

Post by pbreed »

In the latest code release there is a hirestimer.cpp in the MOD5441X directory...
Try using that...

Paul
barttech
Posts: 135
Joined: Fri Feb 20, 2009 12:59 pm

Re: Stopwatch.h for MOD54415?

Post by barttech »

Thanks Paul,
Is there any documentation for this and other new functions beyond the comments in the code?
Or examples?
Like, in void HiResTimer::delay(double delayTime), is delayTime in msec or usec or something else?
Do I have to call start() before using delay()?
The .h file says
"Starts the selected timer. The user MUST call HiResTimerInit for the given timer before calling this method."
but I cannot find HiResTimerInit, does it mean HiResTimer.init() ?
What does the parameter InterruptTime mean for init()?
etc.
Thanks,
Sam
barttech
Posts: 135
Joined: Fri Feb 20, 2009 12:59 pm

Re: Stopwatch.h for MOD54415?

Post by barttech »

If I try:
#include <HiResTimer.h>
HiResTimer MOD54415Timer(1);
MOD54415Timer.init();
I get errors that the constructor and destructor are private.
?
Sam
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Stopwatch.h for MOD54415?

Post by rnixon »

In cpp a constructor is called when you create the object, and the destructor is called when the object goes out of scope. So you don't call those directly. I don't have the code to look at, but maybe that info will help a bit.
barttech
Posts: 135
Joined: Fri Feb 20, 2009 12:59 pm

Re: Stopwatch.h for MOD54415?

Post by barttech »

Right, but usually there is a public constructor, HiResTimer's are private. I'm guessing that one of the other methods also constructs but I can't see what or how.
Thanks,
Sam
greengene
Posts: 164
Joined: Wed May 14, 2008 11:20 am
Location: Lakeside, CA

Re: Stopwatch.h for MOD54415?

Post by greengene »

did you look at the example in /nburn/examples/utils/HiResTimerDemo?
barttech
Posts: 135
Joined: Fri Feb 20, 2009 12:59 pm

Re: Stopwatch.h for MOD54415?

Post by barttech »

Nope, I missed that one, thanks!
It looks like it will answer my questions.
Sam
User avatar
dciliske
Posts: 623
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: Stopwatch.h for MOD54415?

Post by dciliske »

As the developer responsible for the port from Larry's original StopWatch library, I'll try to clarify a couple things.

First of all, my apologies for the typo in the header file when referring to HighResTimer.init(). There is a full set of documentation in the Runtime Library document, in section 22.

As for the issue with the constructor, this was a deliberate design choice. The HighResTimer acts as a user friendly interface onto the processor's DMA timers. With this in mind, it should be obvious that there is a finite supply of potential HighResTimers. Therefore, the class is designed to enforce safe utilization of the resources and deny unrestricted access to instantiation of timers. If you are familiar with design patterns, you will note that this is a Singleton class, with multiple instances.
Dan Ciliske
Project Engineer
Netburner, Inc
barttech
Posts: 135
Joined: Fri Feb 20, 2009 12:59 pm

Re: Stopwatch.h for MOD54415?

Post by barttech »

Thanks Dan,
Somehow I thought the HiRes timer was newly implemented for the MOD54415, so I didn't look in the Runtime Libraries docs. My bad.
Sam
Post Reply