Questions and discussions about the hardware aspects of the TD RF modules, boards and accessories.
disk91
 
Posts: 58
Joined: Thu May 07, 2015 4:30 pm

Timer usage

by disk91 Thu Mar 17, 2016 7:05 am

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
disk91
 
Posts: 58
Joined: Thu May 07, 2015 4:30 pm

Re: Timer usage

by disk91 Thu Mar 17, 2016 6:55 pm

Looks like this question sound like how to switch from EM2 sleep mode to EM1 ...
Some help ?
User avatar
lcheminade
 
Posts: 145
Joined: Mon May 11, 2015 7:47 am

Re: Timer usage

by lcheminade Fri Mar 18, 2016 4:34 pm

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?
disk91
 
Posts: 58
Joined: Thu May 07, 2015 4:30 pm

Re: Timer usage

by disk91 Sat Mar 19, 2016 12:36 pm

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 ?
User avatar
lcheminade
 
Posts: 145
Joined: Mon May 11, 2015 7:47 am

Re: Timer usage

by lcheminade Sat Mar 19, 2016 2:49 pm

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.
disk91
 
Posts: 58
Joined: Thu May 07, 2015 4:30 pm

Re: Timer usage

by disk91 Sat Mar 19, 2016 9:07 pm

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
User avatar
lcheminade
 
Posts: 145
Joined: Mon May 11, 2015 7:47 am

Re: Timer usage

by lcheminade Sun Mar 20, 2016 8:51 am

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.
disk91
 
Posts: 58
Joined: Thu May 07, 2015 4:30 pm

Re: Timer usage

by disk91 Sun Mar 20, 2016 4:02 pm

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
disk91
 
Posts: 58
Joined: Thu May 07, 2015 4:30 pm

Re: Timer usage

by disk91 Wed Mar 23, 2016 10:21 pm

Not really clear but by using a prescaller it seems that it is working really better. Now my timing are quite good.
disk91
 
Posts: 58
Joined: Thu May 07, 2015 4:30 pm

Re: Timer usage

by disk91 Sat Mar 26, 2016 9:53 am

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
Return to Hardware

Who is online

Users browsing this forum: No registered users and 1 guest