Capture/Compare Units

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

cross mob
User5327
Level 4
Level 4
Hi all,
Is it possible in XMC4500 (in some mode) direct write value into Compare register (CCXyCR) ??
... -> without using shadow register (in my case I dont use cap/com for PWM ... but only for control time for interrupt)

Because in my case I need to change contents of compare reg. during each period - in depends on
some measured variable. (not only before period start or before timer start)
(I want let timer running 0 - 0xFFFF -> and by compare register control time of each next interrupt)


If this not possible ... there is second way:
Is it possible to call shadow transfer trig by sw (because only by period match is not enought)


I wanted to use CCU4 or CCU8 ... but maybe there is better way... pls advice

Best regards
Koumak
0 Likes
4 Replies
Not applicable
Hi Koumak,

It is possible to do the shadow transfer via software.
You just need to set the GSCC register when you want to do shadow transfer.
0 Likes
User5327
Level 4
Level 4
Hi Jackson,
are you sure?
I think you mean GCSS register ... but by this register I can only enable the shadow transfer ... but then I must to wait then shadow transfer triggers occur.
=> I need to call this trigger. (In reference manual is written that this trigger occur "every time that an overflow occurs (period match)" )
And question is ... how can I do this? (can I change contents of period register or compare register without waiting on trigger occur?)
0 Likes
User5327
Level 4
Level 4
Can someone help me?
It is important for my project.
Thanks.
0 Likes
pcosta
Employee
Employee
Koumak,

Do you compute the next interrupt time before the current interrupt time is over?

I don't know your application, but by the description that you gave, a pipeline computation of the interrupt time is always needed because if you don't do this, than you can never guarantee that you
are not loading a new interrupt value into the compare register, when the timer has already passed through this value. Something like this:
Initial_int_time = 300;
Next_int_time = 400; (therefore giving you the difference of 100 that is want you want)
But at the time that you load 400, the timer may by already at 410, therefore you don't get a difference of 100 but you get 0xFFF-300+410!

I would do a pipeline computation and then I would do something like this:
Forcing a clear/restart of timer whenever it reaches the current interrupt time that you want.
At the same instant it would load the next interrupt time that you have already compute/programm into the CRS register.

So, if you are in fact doing pipeline computation, I would use something like this (for CCU4 module and Timer Instace 0/CC40):

Initial config:
//NOTE:I am not putting here the initial config for starting the
//timer that you should already have in your code

CCU40_CC40->TC |= 0x4; //enables the shadow transfer whenever the timer is cleared
CCU40_CC40->PRS = 0xFFFF;
CCU40_CC40->CRS = ;
CCU40->GCSS = 0x1; //loads the first interrupt value into the timer

//configuring the timer to be cleared in each interrupt with its own output
CCU40_CC40->INS |= 0x1000C; //Connect Event 0 to the CCU40.ST0 signal (the output of Timer 0) and select active on rising edge
CCU40_CC40->CMC |= 0x4; //configures Event 0 to be used as stop function
CCU40_CC40->TC |= 0x100; //stop is used only as a timer flush

//enabling the Compare Match interrupt on service request line 0
CCU40_CC40->INTE |= 0x4; //enables the compare match while counting up interrupt

So... now you can start the timer via SW:
CCU40_CC40->TCSET |= 0x1; //starts counting

//Your loop should be something like this
//but like I mention above you need to compute the next interrupt time,
//before the current interrupt time is elapsed (pipeline computation)
CCU40_CC40->CRS = ;
CCU40->GCSS = 0x1; //requests an update whenever the timer is cleared (which means whenever the timer reaches the previous interrupt value)
0 Likes