Reset counter of GTM TOM Channel pwm

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

cross mob
FD_aurix
Level 5
Level 5
100 sign-ins 100 replies posted 5 solutions authored

Hi

I'm looking for a way to be sure two different channels of a TOM set as Master channels (indipendentsRST_CCU0  = 0) that works at different frequency are in sync with the edges.

As an example I want that channel X works at 4kHz and channel Y at 10kHz . Each 4 periods at 4kHz or each 10 period at 10kHz they should have a common edge and I want that this is sync.

I might rise an interrupt before the reload on the channel that might reset the other to set some register, but how can I perform the reset of the counter of one channel? I can't switch RST_CCU0 to propagate TRIG X of the previous channel (TRIGX-1) because it will set also the control mode of the TOM (the use of CM0 and CM1 register).

there is any  HW way to do this reset?

0 Likes
7 Replies
Anupama_A
Moderator
Moderator
Moderator
50 solutions authored 10 likes received 250 sign-ins

Hi @FD_aurix ,

 

Are you using MCAL or iLLD based driver?

0 Likes
FD_aurix
Level 5
Level 5
100 sign-ins 100 replies posted 5 solutions authored

I'm familiar with both but I'm doing a custom driver

0 Likes
FD_aurix
Level 5
Level 5
100 sign-ins 100 replies posted 5 solutions authored

Any Reply?

0 Likes
Anupama_A
Moderator
Moderator
Moderator
50 solutions authored 10 likes received 250 sign-ins

Hi @FD_aurix ,

 

Apologies for the delay from my side. We could make use of TBU timestamp here. The register that is used in this case is the Action Time base register. For TOM, it is GTM_TOM[i]_TGC[y]_ACT_TB. So, here when the selected TBU timer matches the ACT_TB value, then a trigger(if requested by the TB_TRIG bit) will be issued. Example of the code for your use case is shown below: 

 

    GTM_TOM0_TGC0_ACT_TB.B.TBU_SEL = 0 ; //select TBU0
    GTM_TOM0_TGC1_ACT_TB.B.TBU_SEL = 0 ; //select TBU0

    GTM_TOM0_TGC0_ACT_TB.B.ACT_TB = 20000 ;    //CH0 -> 10KHz
    GTM_TOM0_TGC1_ACT_TB.B.ACT_TB = 50000 ;    //CH8 -> 4 KHz

    GTM_TOM0_TGC0_ACT_TB.B.TB_TRIG = 1 ;
    GTM_TOM0_TGC1_ACT_TB.B.TB_TRIG = 1 ;

    //Enable TBU channel 0 and wait for the compare match to start all the channels
    GTM_TBU_CHEN.B.ENDIS_CH0 = 2;

 

Here, I'm using TOM0 CH0 and CH8. the output waveform can be observed below: 

Anupama_A_0-1705052151315.png

 

Please let me know if this fulfils your requirement. 

 

Best Regards,
Anupama.

0 Likes
FD_aurix
Level 5
Level 5
100 sign-ins 100 replies posted 5 solutions authored

Thanks Anupama for the feedback

From what I've understood (In any case I'll take later a better look) your proposal is to use TBU mobule to create a force update event periodically for TOM channels.

The problem I see here is that TBU will use CMU CLK and TOM will use FXCLK  that (as far as I know) are not guarantee to be sync. Doing in this way the risk is that sometime a +/-1 count happens

0 Likes
Anupama_A
Moderator
Moderator
Moderator
50 solutions authored 10 likes received 250 sign-ins

Hi @FD_aurix ,

 

Could you please elaborate more on the last line "The problem I see here is that TBU will use CMU CLK and TOM will use FXCLK  that (as far as I know) are not guarantee to be sync. Doing in this way the risk is that sometime a +/-1 count happens" ? As we're using the same TBU i.e. TBU_TS0 for both the channels, I don't think there should be any problem. Also, as you can see from the screenshot attached also, we're able to observe the expected waveform. Do you see any deviations at your end?

 

Best Regards,
Anupama.

 

0 Likes
FD_aurix
Level 5
Level 5
100 sign-ins 100 replies posted 5 solutions authored

Hello Anupama. I've just read your comment so I don't have any implementation so far. My reply was a comment on your proposed solution.

TBU clock source is CMU_CLK

TOM clock source is FX_CLK 

CMU_CLK and FX_CLK are not guarantee to be sync

 

if TBU unit generate a Force update trig signal this one might me not in sync with the TOM clock so sometime I could expect a +/-1 count on TOM counters.  So, as a general behavour it should work, I need to check if in my case this could generate unwanted additional transitions or missing transition on the output.

0 Likes