How can I reset the floating prescaler value

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

cross mob
User10696
Level 4
Level 4
First solution authored
I am using a CCU4 in capture mode with a floating prescaler.
I need to be able to reset the time measurement. If I only reset the timer the prescaler is not reset, so the next measurement is incorrect.

According to the XMC library documentation, it is possible to set the prescaler (XMC_CCU$_SLICE_SetPrescaler), but this is only possible if the prescaler is stopped.
The problem is the XMC_CCU4_StopPrescaler() stops the prescaler for all the slices, this is not what I want to do as this will disturb the other slices.

What is the correct way to restart a measurement (reset prescaler and timer)?
0 Likes
6 Replies
lock attach
Attachments are accessible only for community members.
Mike1
Employee
Employee
5 sign-ins First question asked 10 replies posted
Hi amanning,

In Floating Prescaler mode, the prescaler is reset after a capture automatically. Please see the attached example with simple GUI running on the XMC14xx. Every time a capture is triggered the timer resets and the pre-scaler resets.

Best regards,
Mike

0 Likes
User10696
Level 4
Level 4
First solution authored
Yes, I know that the prescaler is reset when a value is captured, but I need to be able to reset the timer and prescaler from the software. This is in the case when an error occurs or the capture event timesout.

I have found a horrible work-around. By changing the mode back to fixed prescaler and then to floating prescaler, the floating prescaler then restarts with the initial value.
0 Likes
Eric1
Employee
Employee
Hi Amanning,

regarding SW control you could use the Globel start bit.

3464.attach

GLOBAL_CCU4_SyncStartTriggerHigh(GLOBAL_CCU4_CCUCON_Msk);
GLOBAL_CCU4_SyncStartTriggerLow(GLOBAL_CCU4_CCUCON_Msk);
0 Likes
Mike1
Employee
Employee
5 sign-ins First question asked 10 replies posted
With the floating prescaler you can go a very long time between events. But if you want, it is easy to manually trigger a capture event to force the timer and prescaler to reset. The easiest way to do this is to write to the SWS.SExA bit to trigger the capture and restart the timer and prescaler.

My preference would be to set the SExA bit using the XMCLIb function like this (assuming CCU40 Slice 0 and event 1): XMC_CCU4_SLICE_SetEvent(CCU40_CC40, XMC_CCU4_SLICE_IRQ_ID_EVENT1);
0 Likes
User10696
Level 4
Level 4
First solution authored
Hello Eric

Using the global start bit would effect the the other slices in the same timer. This is not a good idea.
0 Likes
User10696
Level 4
Level 4
First solution authored
Hello Mike

Triggering a capture event would be a possibility, but it also has some disavantages. The capture event would also trigger the interrupt, so this reset sequence would need to be handled in the interrupt routine, or the interrupt needs to be disabled before triggering the event and the interrupt request cleared before re-enabling the interrupt. This is of cause possible but a bit messy.
0 Likes