zhuilu 发表于 2011-4-13 10:09:51

这个程序哪有问题?为什么运行不了

#include "msp430x22x4.h"
int zdxh,steps_down_con=3,tiaoshi;
int main( void )
{   
P1OUT = 0;
P1DIR |= BIT0 ;//P1.0为输出方式


   P2IE=0xc1;//p2.6/p2.7允许中断
P2IES=0x00;//上升沿
    __bis_SR_register(GIE);
while(1)
{
}

}

#pragma vector=PORT2_VECTOR
__interrupt void Port_2(void)
{
        zdxh=P2IFG&0xc1;
   if(zdxh==128)
   {
   steps_down_con+=1;
   P1OUT^=0x01;
   }
   if(zdxh==64)
   {
   steps_down_con-=1;
   P1OUT^=0x01;
   }
   if(zdxh==1)
           tiaoshi=1;
   P2IFG=0;
}


程序总是进入不了中断?

seawind319 发表于 2011-4-13 11:08:37

IO输出怎么进入中断?   怎么个上升沿下降沿    外部中断都是输入的

cike 发表于 2011-4-13 22:43:44

应该先设置方向再设置P1OUT吧?直接if(P2IFG&BIT6){} if(P2IFG&BIT7){}

titrwh 发表于 2011-6-18 16:51:21

怎么没有关狗?
页: [1]
查看完整版本: 这个程序哪有问题?为什么运行不了