Quantcast
Channel: MSP 低功耗微控制器论坛 - 最近的话题
Viewing all articles
Browse latest Browse all 3634

Capacitive-Touch 使用定时器timerA1 count没有值的问题 - msp430g2553

$
0
0

使用Capacitive-Touch Pins做触摸检测,参考官方msp430g2xx3_pinosc_04.c,P2.0作为输入,使用的时timerA0,Demo没有问题。

现在把定时器换为timerA1,获取不到count值,请教这是为什么?

/**
 * @brief    触摸检测初始化,使用定时器的捕捉模式
 * @Author   WuWenhua
 * @DateTime 2018-06-26
 */
void touch_init(void)
{
	P2DIR  &= ~TOUCH_PIN;
	P2SEL  &= ~TOUCH_PIN;
	P2SEL2 |=  TOUCH_PIN;				// input oscillation feeds TACLK

	TA1CTL   = TASSEL_3 + MC_2;			//	时钟源:INCLK, 连续模式:定时器计数增加至0FFFFh。
	TA1CCTL1 = CM_3 + CCIS_2 + CAP;		// 上升沿和下降沿二者的捕捉,TACCRx 输入信号:GND,捕捉模式
}


/**
 * @brief    获取触摸测量结果值
 * @Author   WuWenhua
 * @DateTime 2018-06-26
 * @return                          [description]
 */
uint16 touch_measure(void)
{
	uint16 count = 0;

	touch_init();						// 初始化触摸设置

	TA1CTL |= TACLR;					// Clear Timer_A TAR

	delay_ms(1);

	TA1CCTL1 ^= CCIS0;               	// Create SW capture of CCR1
	count     = TA1CCR1;                // Save result
	P2SEL2   &= ~TOUCH_PIN;
	TA1CTL    = 0;						// Stop Timer_A

	return count;
}


Viewing all articles
Browse latest Browse all 3634

Trending Articles