TI中文支持网
TI专业的中文技术问题搜集分享网站

MSP430 G2553 Timer_A主定时器外部时钟输入

写了个小的测试程序,使用外部时钟输入,但是总没有计数的效果。输入的信号是信号发生器产生的方波(-3V~3V,频率32768Hz),代码如下:

#include "MSP430G2553.h"
#include "LCD_128.h"
#include "HT1621.h"
#include "TCA6416A.h"

unsigned char flag1=0;
unsigned char flag2=0;
unsigned int temp=0;
long temp1;
long FRE=12346;
long adc_sample=0;
long adc_max=0;
unsigned int i;

void main( void )
{
WDTCTL = WDTPW + WDTHOLD; //关狗

TCA6416A_Init();
HT1621_init();

P1DIR |= BIT6; //使用P1.0控制LED闪烁
P1SEL |= BIT0;
P1DIR &= ~BIT0;

TA1CCTL0=CCIE; //Capture/compare interrupt enable
TA1CCR0=32768; //设置计数周期
TA1CTL= TASSEL_0 + MC_1 +TACLR;//选择时钟源,SMCLK;计数模式,连续计数

while(1)
{
_BIS_SR(LPM0_bits + GIE);
temp1=FRE;

}
}

#pragma vector=TIMER1_A0_VECTOR
__interrupt void Timer1_A (void)
{

// _BIC_SR_IRQ(LPM0_bits);
P1OUT^=BIT6;

}

Ling Zhu2:

  你是要用timerA实现对外部脉冲的计数么?

Xiaoguang Wang1:

回复 Ling Zhu2:

是啊,就是直接在P1.0 输入时钟信号  读不出上升沿数据啊

Ling Zhu2:

回复 Xiaoguang Wang1:

明天发给代码你试一下~

Ling Zhu2:

回复 Ling Zhu2:

#include <msp430.h>int main(void)
{WDTCTL = WDTPW | WDTHOLD;// Stop WDT// Configure GPIOP1DIR |= BIT6;P1OUT = 0;P1SEL |= BIT0;// P1.0 selected as TA0CLK// Configure Timer_ATA0CTL = TASSEL_0 | MC_2 | TACLR | TAIE;// ACLK, count mode, clear TAR, enable interruptTA0R = 0xFFFF - 10;// Offset until TAR overflow__bis_SR_register(LPM3_bits | GIE);// Enter LPM3, enable interruptswhile (1){}
}// Timer0_A3 Interrupt Vector (TAIV) handler
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER0_A1_VECTOR
__interrupt void TIMER0_A1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A1_VECTOR))) TIMER0_A1_ISR (void)
#else
#error Compiler not supported!
#endif
{switch(__even_in_range(TA0IV,TA0IV_TAIFG)){case TA0IV_NONE:break;// No interruptcase TA0IV_TACCR1:break;// CCR1 not usedcase TA0IV_TACCR2:break;// CCR2 not usedcase TA0IV_TAIFG:// overflowTA0R = 0xFFFF - 10;P1OUT ^= BIT6;break;default:break;}
}

Ling Zhu2:

回复 Ling Zhu2:

10个脉冲LED翻转一次

赞(0)
未经允许不得转载:TI中文支持网 » MSP430 G2553 Timer_A主定时器外部时钟输入
分享到: 更多 (0)