两个按键控制两个灯两个按键控制两个灯
//******************************************************************************
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= BIT0; // P1.0 output, else input P1OUT |= 0x08; // P1.3 set, else re...
两个按键控制两个灯
//******************************************************************************
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= BIT0; // P1.0 output, else input P1OUT |= 0x08; // P1.3 set, else reset
P1REN |= 0x08; // P1.3 pullup
P1IE |= 0x08; // P1.3 interrupt enabled P1IES |= 0x08; // P1.3 Hi/lo edge
P1IFG &= ~0x08; // P1.3 IFG cleared
P1DIR |= BIT6; // P1.6 output, else input P1OUT |= 0x10; // P1.4 set, else reset
——————————————————————————————————————————————————
———
P1REN |= 0x10; // P1.4 pullup
P1IE |= 0x10; // P1.4 interrupt enabled P1IES |= 0x10; // P1.4 Hi/lo edge
P1IFG &= ~0x10; // P1.4 IFG cleared
__bis_SR_register(LPM4_bits + GIE); // Enter LPM4 w/interrupt
}
// Port 1 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) ||
defined(__IAR_SYSTEMS_ICC__) #pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(PORT1_VECTOR))) Port_1 (void)
#else
#error Compiler not supported!
#endif
{
if(P1IFG&BIT3)P1OUT ^= BIT0; // P1.0 = toggle if(P1IFG&BIT4)P1OUT ^= BIT6;
P1IFG &= ~0x08; // P1.3 IFG ——————————————————————————————————————————————————
———
cleared
P1IFG &= ~0x10; // P1.4 IFG
cleared
}
——————————————————————————————————————————————————
———
本文档为【两个按键控制两个灯】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。