MOD54415 hires timer

Discussion to talk about software related topics only.
Post Reply
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

MOD54415 hires timer

Post by jediengineer »

Hey all,
I'm trying to set up the HIRES timer to trigger an event every tenth of a second. I dug through the example files and looked at the hires timer demo which takes a value from the serial buffer and puts it in the timer like this:

iprintf( "Input number of seconds (floating point) between LED increments:" );
gets( Buffer );
timer->init(strtod( Buffer, NULL ) );

So if I want this timer to fire off my ISR every 10th of a second, can I just replace "buffer" in the timer->init line with a floating point number?

If not, what is a good way to set up a DMA timer without screwing up the uCOS?

Sorry for the dumb question, still learning C++ on the fly.... Thanks!!

Tony
khoney
Posts: 125
Joined: Fri Sep 11, 2009 12:43 pm

Re: MOD54415 hires timer

Post by khoney »

If you really need 1/10 second, just say:

timer->init((double)0.1);

I used a constant for an 8khz timer, and it worked fine.
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: MOD54415 hires timer

Post by tod »

You shouldn't need that explicit cast to double

Code: Select all

timer->init((double)0.1);
0.1 is a double implicitly. 0.1f is the literal syntax for a float.
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 hires timer

Post by jediengineer »

thanks guys! So since the input has to be a floating point number, then I can just use:

timer->init(0.1); ??

I originally declared a floating point constant variable with 0.1 as it's value. If that works the same, then I'm set. Just trying to simplify the code a little. Thanks!!

Tony
Post Reply