This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
使用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; }
可以连到timerA1的,您可以看一下www.ti.com/.../slaa490d.pdf 的 Table 8. halDefinition Descriptions
如果是做产品,并不推荐使用MSP430G系列的,因为它的PIN并不是专门的touch PIN。做个demo还好,难的是量产,虽然我们有不少软件算法,但是实际量产的一致性和对温湿度变化的抵抗力都是很弱的。做Touch不妨看看FR4133系列的,带有Captive touch的I/O,适合touch应用的。