1559 views|0 replies

2015

Posts

0

Resources
The OP
 

MSP430 MCU timer TA counting program [Copy link]

#include

/******************************************************************** * Name: Divider_SetDivFactor * Function: Set the division factor * Input parameter: Factor: division factor (2~65535) * Output parameter: None****************************************************************/ void Divider_SetDivFactor(unsigned int Factor) //Set the division factor { TACCR0=Factor-1; // Division factor = counter overflow period TACCR2=Factor/2; // Duty cycle = 50% } void main( void ) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog FLL_CTL0 |= XCAP18PF; // Configure crystal load capacitance P1DIR &=~BIT5; // P1.5(TACLK) as input pin P1SEL |= BIT5; // Allow its second function as TACLK input P2DIR |= BIT0; // P2.0 as output P2SEL |= BIT0; // Allow P2.0 to have the second function as TA2 output TACTL = TASSEL_0 + MC_1 ; // TA external counting, up counting mode TACCTL2 = OUTMOD_7; // TA2 as output, mode 7 (PWM mode) Divider_SetDivFactor(100); // 100 division while(1) { //CPU can continue to execute other tasks} }


This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list