[CCU8] Updating timer value on the fly

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

cross mob
Not applicable
Hi,

I have configured CCU8 slice to operate as a free running timer, and I need to update a timer value immediately on user request when timer is running. As far as I understand, I have two options.
1. Stop timer, load new value to CC8y.TIMER register, and start timer.
2. Set one of the shadow compare channels SCR1 or SCR2 with the new value, enable shadow transfer, wait for shadow transfer, and trigger external load event.
Former introduce error to time measurement, later is useless because it does not provide an immediate timer update. Is there other, third option?

Regards,
Mariusz
0 Likes
5 Replies
Not applicable
Hi Mariusz,

Do you mean you want to change the timer value or the compare value?
If you want to change the timer value, you can use External Load function.
With external event as the trigger signal, you can change the timer value to the value in the compare register directly.
More information can be found in the "External Load" topic in the device Reference Manual.
0 Likes
Not applicable
Hi Jackson,

I need change timer value. I know that I can use External Load function, and this is the second case I have described. Unfortunately the immediate load is not possible because of shadow transfer. Timer should be updated with new value immediate on user request. In this case the procedure is following:
1. User write new timer value to slice compare shadow register SCR1 or SCR2.
2. User enable shadow transfer in GCSS register.
3. Then we have to wait for shadow transfer (SCRx -> CRx)
a) Period Match while counting up,
b) One Match while counting down,
c) Immediately, if the timer is stopped and the shadow transfer enable bit(s) is set.
4. Finally we can trigger external load function (CRx -> TIMER).

This is not what I need, this procedure does not satisfy the 'immediate load' condition.

Regards,
Mariusz
0 Likes
Not applicable
Hi Mariusz,

As per my understanding, it is not as what you have describe.
If you have set the external trigger event to external load, when the signal is triggered, the timer will be change to the value that is in compare register.
Quoted from Reference Manual "Every time that a rising edge on external signal (1) is detected, the timer value is loaded with the value present on the compare register."
Based on the timing diagram show in the Reference Manual, when the external signal is triggered, the timer value will be loaded to the load value on the next clock cycle.
1219.attach
0 Likes
Not applicable
Hi Jackson,

indeed the timer is loaded immediately after triggering external load signal. However, you assume that compare register (CRy) contains actual value provided by user a moment ago, what is not true in this case. This is due to the fact that user is able to load new value to shadow compare register SCRy and not directly to the compare register CRy. The CRy register will be updated with new value after shadow transfer occur. This can be observed on the figure that you have attached previously.

Regards,
Mariusz
0 Likes
Not applicable
Hi Mariusz,

Yes, this means you have to put in the value you want to change in advance to the shadow register first and wait for the shadow transfer.
As for immediate transfer from shadow register to timer value, currently I do not have any solution.
Let me find out more on this topic and I will update here if there are any solution.
0 Likes