Clearing TCNT counter to 0

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Clearing TCNT counter to 0

Jump to solution
1,791 Views
Pallavi
Contributor II

Hello Everyone. I need a support to clear TCNT register to 0. 

While control comes from boot to App, I need clear TCNT register to 0. 

I aware that , TNCT can't be cleared in normal mode. From google, i understand that below 2 are methods available.

Method 1: Using Timer Channel 7 (Hardware Reset) : As I want to clear TCNT only once, I didn’t try this method.

Method 2:  System/Module Reset (Force Clear)  : I have tried this way . 

  1. Clear the TEN bit (Timer Enable) in the TSCR1 (Timer System Control Register 1) to turn off the timer. TSCR1_TEN =0;
  2. Set the TEN bit to re-enable it (TSCR1_TEN =1 ;). This should clear TCNT to 0000.

 

But this method is not working . Please help me out to solve this issue

0 Kudos
Reply
1 Solution
1,614 Views
Pallavi
Contributor II

Thank you Daniel for confirming.

View solution in original post

0 Kudos
Reply
6 Replies
1,716 Views
Pallavi
Contributor II

Hello , 

I am using MC9S12ZVLA128  

 

0 Kudos
Reply
1,683 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @Pallavi,

Unfortunately, there is no option to clear the counter on S12ZVLA.

However, why would you need to clear it? What would be the use case?

 

BR, Daniel

0 Kudos
Reply
1,673 Views
Pallavi
Contributor II

TCNT has incremented in bootloader before control comes to app. In app, i am calling 10ms, task depending onTCNTcount. 

As of now I am reading the current count and calling 10ms task from that count value. 

Instead of that I thought of clearing TCNT when control comes to app and then schedule 10ms task. 

0 Kudos
Reply
1,666 Views
danielmartynek
NXP TechSupport
NXP TechSupport

You are doing it correctly, this is how output compare is updated.

 

BR, Daniel

0 Kudos
Reply
1,615 Views
Pallavi
Contributor II

Thank you Daniel for confirming.

0 Kudos
Reply
1,754 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @Pallavi,

Can you please specify the MCU?

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2318409%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EClearing%20TCNT%20counter%20to%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2318409%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20Everyone.%20I%20need%20a%20support%20to%20clear%20TCNT%20register%20to%200.%26nbsp%3B%3C%2FP%3E%3CP%3EWhile%20control%20comes%20from%20boot%20to%20App%2C%20I%20need%20clear%20TCNT%20register%20to%200.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20aware%20that%20%2C%20TNCT%20can't%20be%20cleared%20in%20normal%20mode.%20From%20google%2C%20i%20understand%20that%20below%202%20are%20methods%20available.%3C%2FP%3E%3CP%3EMethod%201%3A%20Using%20Timer%20Channel%207%20(Hardware%20Reset)%20%3A%20As%20I%20want%20to%20clear%20TCNT%20only%20once%2C%20I%20didn%E2%80%99t%20try%20this%20method.%3C%2FP%3E%3CP%3EMethod%202%3A%26nbsp%3B%20System%2FModule%20Reset%20(Force%20Clear)%26nbsp%3B%20%3A%20I%20have%20tried%20this%20way%20.%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3E%3CSPAN%3EClear%20the%26nbsp%3BTEN%26nbsp%3Bbit%20(Timer%20Enable)%20in%20the%26nbsp%3BTSCR1%26nbsp%3B(Timer%20System%20Control%20Register%201)%20to%20turn%20off%20the%20timer.%20TSCR1_TEN%20%3D0%3B%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3ESet%20the%26nbsp%3BTEN%26nbsp%3Bbit%20to%20re-enable%20it%20(TSCR1_TEN%20%3D1%20%3B).%20This%20should%20clear%20TCNT%26nbsp%3Bto%200000.%20%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FOL%3E%3CBR%20%2F%3E%3CP%3EBut%20this%20method%20is%20not%20working%20.%20Please%20help%20me%20out%20to%20solve%20this%20issue%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2318991%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Clearing%20TCNT%20counter%20to%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2318991%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F259939%22%20target%3D%22_blank%22%3E%40Pallavi%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3ECan%20you%20please%20specify%20the%20MCU%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2323810%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Clearing%20TCNT%20counter%20to%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2323810%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F259939%22%20target%3D%22_blank%22%3E%40Pallavi%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EUnfortunately%2C%20there%20is%20no%20option%20to%20clear%20the%20counter%20on%20S12ZVLA.%3C%2FP%3E%0A%3CP%3EHowever%2C%20why%20would%20you%20need%20to%20clear%20it%3F%20What%20would%20be%20the%20use%20case%3F%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBR%2C%20Daniel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2324199%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Clearing%20TCNT%20counter%20to%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2324199%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EYou%20are%20doing%20it%20correctly%2C%20this%20is%20how%20output%20compare%20is%20updated.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBR%2C%20Daniel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2324145%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Clearing%20TCNT%20counter%20to%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2324145%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ETCNT%20has%20incremented%20in%20bootloader%20before%20control%20comes%20to%20app.%20In%20app%2C%20i%20am%20calling%2010ms%2C%20task%20depending%20onTCNTcount.%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20of%20now%20I%20am%20reading%20the%20current%20count%20and%20calling%2010ms%20task%20from%20that%20count%20value.%26nbsp%3B%3C%2FP%3E%3CP%3EInstead%20of%20that%20I%20thought%20of%20clearing%20TCNT%20when%20control%20comes%20to%20app%20and%20then%20schedule%2010ms%20task.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2324804%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Clearing%20TCNT%20counter%20to%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2324804%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20Daniel%20for%20confirming.%3C%2FP%3E%3C%2FLINGO-BODY%3E