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
2,236 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
2,059 Views
Pallavi
Contributor II

Thank you Daniel for confirming.

View solution in original post

0 Kudos
Reply
6 Replies
2,161 Views
Pallavi
Contributor II

Hello , 

I am using MC9S12ZVLA128  

 

0 Kudos
Reply
2,128 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
2,118 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
2,111 Views
danielmartynek
NXP TechSupport
NXP TechSupport

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

 

BR, Daniel

0 Kudos
Reply
2,060 Views
Pallavi
Contributor II

Thank you Daniel for confirming.

0 Kudos
Reply
2,199 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @Pallavi,

Can you please specify the MCU?

0 Kudos
Reply