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.

[参考译文] MSP-EXP430FR5969:MSP430

Guru**** 1457880 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1357143/msp-exp430fr5969-msp430

器件型号:MSP-EXP430FR5969

您好!

我正在 YouTube 上的一个示例上、以 通过板载开关 P1.1实施 ISR 来切换 LED P1.0。

除了开关抖动之外、一切都很好-我想知道如何通过软件处理开关抖动、尤其是在中断操作处理时?

下面是我的代码:

//开始主程序
int main (空)
{
//停止看门狗计时器以防止超时复位
WDTCTL = WDTPW + WDTHOLD;

P1DIR  |= BIT0;                 //"设置" P1.0 / LED2 DIR 寄存器(1=输出)
P1OUT &=~BIT0;              //"清除" P1.0 / LED2输出寄存器初始值(0 =低电平)

P1DIR  &=~BIT1;               //清除 P1.1 (开关1;0 =输入)
P1REN |= BIT1;                //启用 PU/FPU 电阻器 PD
P1OUT |= BIT1;                //将电阻器设置为 pu
P1IES  |= BIT1;                 //中断边沿灵敏度设置 H 到 L

PM5CTL0 &=~μ A LOCKLPM5;      //解锁数字 I/O

P1IE |= BIT1;                  //启用 P1.1 IRQ
__enable_interrupt ();            //启用可屏蔽 IRQ
P1IFG &=~BIT1;               //清除 P1.1 IRQ 标志

同时  (1){}

返回 0

//设置 ISR
#pragma vector = Port1_vector
__中断 ISR_Port1_S1 (空)
{
P1OUT ^= BIT0;
P1IFG &=~BIT1;

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    对开关进行去抖的方法有很多种。 选择一个。