Page 1 of 1

Timer usage

Posted: Thu Mar 17, 2016 7:05 am
by disk91
Hello, I need to use a high frequency timer to measure short timing. Apparently the Timer1 use impacts the Scheduler code. What timer can I choose safely ?

Second point td_timer.h do not export TickUser with a geter or in .h files so I assume the sdk could be improved for this file.

Sincerely,
Paul

Re: Timer usage

Posted: Thu Mar 17, 2016 6:55 pm
by disk91
Looks like this question sound like how to switch from EM2 sleep mode to EM1 ...
Some help ?

Re: Timer usage

Posted: Fri Mar 18, 2016 4:34 pm
by lcheminade
You mean you need a resolution lower than the tick (1/32768)? You should be able to use TIMER1 since the scheduler is based on LETIMER. What are you trying to achieve?

Re: Timer usage

Posted: Sat Mar 19, 2016 12:36 pm
by disk91
I try to measure a short timining like 100uS with a 10uS precision ; so I need a timer with a frequency about 100KHz. I'm trying to use timer.c code as a reference but it seems it is not working to not say it is crashing the EFM. as an exemple this code never print the second printf :

TD_RTC_SetPowerMode(TD_RTC_EM1);
TD_RTC_Delay(5*T1S);

tfp_printf("Ready .. Go !\r\n");
my_TIMER_resetTicks();
my_TIMER_Start(100000);
TD_RTC_Delay(5*T100MS);
my_TIMER_Stop();
tfp_printf("Timer : %d us\r\n",10*(int)my_TIMER_getTicks);

my_TIMER... are copy/paste of timer.c code just add some function to access the timer value.

Any idea ?

Re: Timer usage

Posted: Sat Mar 19, 2016 2:49 pm
by lcheminade
First the scheduler is based on RTC, not LETIMER, my bad.

Then yes you need to use TIMER0 or TIMER1 to do so. If you're trying to count time between some I/O event it can do it automatically. But you can also have it just count.

Please see AN0014 from silabs about the timer:

http://www.silabs.com/products/mcu/Page ... notes.aspx

and have a look at AN0014SW code example. Reference manual should help as well.

Re: Timer usage

Posted: Sat Mar 19, 2016 9:07 pm
by disk91
Thank you for your reply. I fix my bug that was causing the interrupt to crash the system.
Actually I have a Timer working but i'm not able to get the right timing. Whatever the TOP value I'm setting the result is always the same ... I'm getting about 2400 overflow interrupt for 200ms about 6200 for 500ms
Any idea where it could come from ? I read different AN many times and tryed different way or doing but results looks the same.
Paul

Re: Timer usage

Posted: Sun Mar 20, 2016 8:51 am
by lcheminade
I'll give it a try. Are you trying to do an active wait or just time counting? For active wait you can use the TD_RTC_CalibratedDelay function which take µs as parameter.

Re: Timer usage

Posted: Sun Mar 20, 2016 4:02 pm
by disk91
I want to do time counting :
I have a external signal firing interrupt rising and falling edge
I try to measure time between rising and falling event.
The timing is about 100uS
Here is the goal ;)

I have tried the following :
TD_RTC_CalibratedDelay(6000000);

It seems to have a duration of some ms no more ... for sure not 6s ... normal ?
Paul

Re: Timer usage

Posted: Wed Mar 23, 2016 10:21 pm
by disk91
Not really clear but by using a prescaller it seems that it is working really better. Now my timing are quite good.

Re: Timer usage

Posted: Sat Mar 26, 2016 9:53 am
by disk91
It taken me some time but I found the right way for doing it !!
Here are my note for sharing with the community
https://www.disk91.com/2016/technology/ ... 32-td1208/

Sincerely,
Paul