Synchronous Start/Stop Counting on XMC1300 CCU8 Slices

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

cross mob
User11506
Level 2
Level 2
Hi everybody! 🙂

I am playing with the XCM1300 series,

I am using the slices 0,1 and 2 of the CCU8 in order to generate three triangular signals.

I want the three of them to start/stop counting exactly at the same time, using a software variable.

So far I have been using the following code in order to start/stop the counting:

---------------------------------------START COUNTING------------------------------------------------------

XMC_CCU8_SLICE_StartTimer(CCU80_SLICE0_PTR);
XMC_CCU8_SLICE_StartTimer(CCU80_SLICE1_PTR);
XMC_CCU8_SLICE_StartTimer(CCU80_SLICE2_PTR);

---------------------------------------STOPCOUNTING--------------------------------------------------------

XMC_CCU8_SLICE_StopTimer(CCU80_SLICE0_PTR);
XMC_CCU8_SLICE_StopTimer(CCU80_SLICE1_PTR);
XMC_CCU8_SLICE_StopTimer(CCU80_SLICE2_PTR);

Does this ensure a synchronous start/stop of the counting? If not , could you please give me a hint about how to do it.

Thank you!

Regards!

Paul.
0 Likes
4 Replies
User7282
Level 4
Level 4
Hello Paul,

No, that does not ensure the synchronous start/stop of the timers.
In order to do that, you have to associate an start/stop event to each timer slice, connect it to the input signal H and then call a specific SCU function.

So define an event like this:


XMC_CCU8_SLICE_EVENT_CONFIG_t CCU8_0_event0_config = {
.mapped_input = XMC_CCU8_SLICE_INPUT_H,
.edge = XMC_CCU8_SLICE_EVENT_EDGE_SENSITIVITY_RISING_EDGE,
.level = XMC_CCU8_SLICE_EVENT_LEVEL_SENSITIVITY_ACTIVE_LOW,
.duration = XMC_CCU8_SLICE_EVENT_FILTER_DISABLED
};


Then configure the CCU80 start events like this:


XMC_CCU8_SLICE_ConfigureEvent(CCU80_SLICE0_PTR, XMC_CCU8_SLICE_EVENT_0, &CCU8_0_event0_config);
XMC_CCU8_SLICE_StartConfig(CCU80_SLICE0_PTR, XMC_CCU8_SLICE_EVENT_0, XMC_CCU8_SLICE_START_MODE_TIMER_START);


At last, request the synchronous start of all the timer slices from CCU80:


XMC_SCU_SetCcuTriggerHigh(XMC_SCU_CCU_TRIGGER_CCU80);
0 Likes
User11506
Level 2
Level 2
Thanks a lot!

I haven't got time to try it yet, but I will do it along this week! 😄
0 Likes
User11506
Level 2
Level 2
Hello!

I got to test the synchronization start of the counters and it works very nice.

The difference can clearly be seen below, where I have measured the PWM outputs generated by the three counters using the same Duty Cycle.

No synchronized start:
2067.attach


Synchronized start:
2068.attach

Thanks a lot! 🙂
0 Likes
User7282
Level 4
Level 4
Hello Paul,

No problem, you are welcome. 🙂
0 Likes