Page 1 of 1

MOD54415 hires timer

Posted: Fri Mar 08, 2013 10:32 am
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

Re: MOD54415 hires timer

Posted: Fri Mar 08, 2013 12:37 pm
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.

Re: MOD54415 hires timer

Posted: Fri Mar 08, 2013 5:28 pm
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.

Re: MOD54415 hires timer

Posted: Mon Mar 11, 2013 8:20 am
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