Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

How to read the current counter value of timer

$
0
0

Hello, 

 

I want to perform something simple like a time measurement.

 

With AtTiny i can use the TCNT0 register/variable to read the current counter value and reset it with TCNT0 = 0;

 

 

 

I used this Code for timer init:  (MSP430G2533 )

 
TA1CCR0 = 1000-1;                 // Count limit (16 bit)
TA1CCTL0 = 0x10;                 // Enable Timer A0 interrupts, bit 4=1
TA1CTL = TASSEL_2 + MC_1 + ID_0; // TASSEL_2  = SMCLK @ 1MHz, Up Mode, no prescaler

 

 

 

 

Is this the correct syntax for reset the counter vaulue?

 

TA1CTL |= TACLR

 

 

How can i read the current counter value before it reaches the value TA1CCR0 ?

 

 


Viewing all articles
Browse latest Browse all 2077

Trending Articles