Feb 15, 2019
04:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 15, 2019
04:25 AM
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)?
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)?
6 Replies
Attachments are accessible only for community members.
Feb 19, 2019
08:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 19, 2019
08:41 AM
Feb 20, 2019
12:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 20, 2019
12:15 AM
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.
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.
Feb 20, 2019
12:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 20, 2019
12:59 AM
Hi Amanning,
regarding SW control you could use the Globel start bit.
GLOBAL_CCU4_SyncStartTriggerHigh(GLOBAL_CCU4_CCUCON_Msk);
GLOBAL_CCU4_SyncStartTriggerLow(GLOBAL_CCU4_CCUCON_Msk);
regarding SW control you could use the Globel start bit.
GLOBAL_CCU4_SyncStartTriggerHigh(GLOBAL_CCU4_CCUCON_Msk);
GLOBAL_CCU4_SyncStartTriggerLow(GLOBAL_CCU4_CCUCON_Msk);
Feb 20, 2019
02:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 20, 2019
02:03 PM
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);
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);
Feb 21, 2019
10:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 21, 2019
10:57 PM
Hello Eric
Using the global start bit would effect the the other slices in the same timer. This is not a good idea.
Using the global start bit would effect the the other slices in the same timer. This is not a good idea.
Feb 21, 2019
11:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 21, 2019
11:02 PM
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.
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.