Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

DAVE™ Forum Discussions

Not applicable
Hello,

im using the TIMER APP in Dave 4.3 with an XMC4500.
Is there any way to calculate the actual Resolution of the TIMER?

thanks
Lukas
0 Likes
3 Replies
DRubeša
Employee
Employee
First solution authored First like received
HI Lukas,

so to explain the logic behind the algorithm I will use this code section that is part of TIMER.manifest (files they generate code for the APPs). You can find this file under "/Dave/Model/APPS/TIMER/v4_1_10/TIMER.manifest".


/*
* Based on the input clock frequency and input time interval least possible prescaler is calculated. So that error is less.
* This value is used during code generation in templates.
*/
timer_prescaler.value = MF({Integer prescaler = 0
Double Clock_Period_min = 0
Double Clock_Period_max = 0
for(prescaler = 0; prescaler <= prescaler_maxvalue; prescaler++)
{
Clock_Period_min = timer_resolution(timer_clock_mhz.value,prescaler); /* convert to usec */
Clock_Period_max = Clock_Period_min * period_16bit_maxvalue; /* convert to usec */

if(gfloat_time_interval.value <= Clock_Period_max)
break;
}


As you can see, the algorithm tries to find the least possible prescaler value with which is possible generate wished time interval. Prescaler value is just something that divides frequency clock so for example; XMC4500 has clock frequency of 120 MHz, meaning that the finest achievable frequency is 1/120 MHz or 8.33ns. If you multiply that value with maximum 16 bit value (while the period register in TIMER is 16 bit wide), then you get possibility of generating time interval in this range [8.33 ns - 0.546 ms]. And if your desired time interval is for example, 10 ms, you can see that wished interval cannot be generated with such a resolution, so TIMER APP will try to find next suitable prescaler value. If you want more control over resolution value that should be used then I suggest that you take a look at CCU4/CCU8_SLICE_CONFIG APPs where you can immediately see which resolution will be used. But as I said, it´s fairly easy to calcute it in this case too.

Best regards,
Deni
0 Likes
Not applicable
Hi Deni,

thanks for the explanation, but where do i find CCU4/CCU8_SLICE_CONFIG APPs?

Best reards,
Lukas
0 Likes
DRubeša
Employee
Employee
First solution authored First like received
Hi Lukas,

try under "Add new APP":

1955.attach

And then under "Search filter" start entering text like "CCU" and you can see that in my case both APPs are visible:

2941.attach

If those APPs are not listed that could mean they are not installed. So go to "Help"-> "Install DAVE APP/ Example/...".There under "Work with:" select "DAVE APPs Library Manager". And again, under "Enter the keywords to filter" write something like "CCU"...you should see it there. Check also that maybe the fitter "Hide items that are already downloaded" is enabled. But that could just mean you already have downloaded the APP. So yes, you should be able to find it one way or another.

Best regards,
Deni
0 Likes