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

XMC™ Forum Discussions

User15071
Level 1
Level 1
Hello,

My XMC4400 runs at 120[MHz] which is also the input clock frequency to CCU4 (and 8). In order to make my timer tick every microsecond I need to divide the input clock by 120, but the best available match is 128.
Is there a way to achieve the desired frequency without interrupts, without the SysTick etc.? PWM generation is quite flexible, but can it be used to maintain a free running timer (again, minimizing software
involvement in counter management)?

Thanks in advance.
0 Likes
6 Replies
User15087
Level 2
First like received
Level 2
You can use CCU timer concatenation for this. Configure one slice to run at 1 MHz and then use this an an input to the next timer slice.
0 Likes
User15071
Level 1
Level 1
Thanks, but I don't see how this helps me, as I initially strived to do exactly what you suggest - set my timer frequency to 1[MHz] (but that does not seem to be possible if my CCU's input clock is 120[MHz]...?).
0 Likes
User14604
Level 4
First solution authored
Level 4
The following is based on XMC4300/4800, I hope it is similar to XMC4400:
You can define the timer period in register PRS, which marks the top to which the timer will run (starting from 0).

Please see the attached code for XMC4300/4800. Try calling TIMER_init(0, 120, true) to generate in interrupt every 1 us. Could be there's not enough time to do anything in ISR, because 1 us is very fast.
0 Likes
User15071
Level 1
Level 1
Maybe I can connect a high frequency CCU unit (120[MHz], 8,3[ns]) to another CCU unit, and trigger CCU timer increment upon 120 counts.
0 Likes
User15087
Level 2
First like received
Level 2
As an example, the following code will set the period CCU40_CC40 to 1 microsecond, assuming a 120 MHz clock:

#define PERIOD_1US    (120U)
XMC_CCU4_SLICE_SetTimerPeriodMatch(CCU40_CC40, PERIOD_1US - 1);
XMC_CCU4_SLICE_SetTimerCompareMatch(CCU40_CC40,PERIOD_1US / 2);


Then make sure to set timer_concatenation = true when configuring CCU40_CC41. This slice will now run with 1 MHz input clock from slice 0.
0 Likes
User15071
Level 1
Level 1
I see what you mean, which is actually almost identical to what I posted just before you. In both cases I need 2 slices. Thanks.
0 Likes