请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
部件号:MSP430FR4133 工具/软件:Code Composer Studio
大家好,
如果我使用以下代码,则只能执行一个班次操作。 此后,将不会执行犁沟机换档操作。 我认为这与IFG有关,因为它是为WFP 1.2 的
P1IFG &=~BIT2; //已清除WFP 1.2 IFG
#include <msp430fr4133.h>
#include <driverlib.h>
#include "main.h"
#include "hal_lcd.h"
#include <stdio.h>
// Port 2中断服务例程
#pragma vector=port2_vector
__interrupt Port_2 (void){
while (TA1R1/CC900...
{
TA1CCR1 ++++;// 增加TA1CCR1 (占空比)
_DELAY _CYCLES (8万); //延迟时间
}
P2IFG &=~BIT6;// WFP 2.6 IFG清除
}//
端口1中断服务例程
#pragma vector=Port1_vector
__interrupt Port_1(void)
{
P1OUT>=1; 端口1;端口
1端口1 =右移~1 //已清除WFP 1.2 IFG
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;//停止WDT
PM5CTL0 &=~LOCKLPM5; //禁用GPIO通电默认高阻抗模式
//要激活先前配置的端口设置
TA1CCR0 = 1000-1;
TA1CCR1 = 0; //占空比
TA1CTL = tassel_2 | MC_1;
TA1CCTL1 = OUTMOD_7; // PWM模式下的计时器
P1DIR = 0xFB; //设置端口WFP 1.0 ,WFP 1.1 ,WFP 1.3 ,... WFP 1.7 作为输出方向
P1OUT = 0xEF; //打开WFP 1.0 ,WFP 1.1 ,WFP 1.3 ,...
~1.7 P4DIIR |= BIT0;// WFP 4.0 2.6 P4SEL0 |= BIT0;//定时器选择到WFP 4.0 P2REN |= BIT6;//为WFP 2.6 P2OUT |= BIT6启用内部上/下电阻器;//为WFP P2IE |= BIT6;// 2.6 P2ITE= 2.6 中断 //WFP 2.6 IFG Cleared
P1REN |= BIT2;//为WFP 1.2
P1OUT |= BIT2;//为WFP 1.2
P1IE |= BIT2;// WFP 1.2 interrupt enabled
P1IES |= BIT2;// 1.2 GOOFIG/LO EDGE P1IFG|= 1.2
~BIST_FIG;//已清除
//输入LPM0 w/ interrupt while
(1)//Loop forever,我们使用interrupt
{}
但是,如果我在没有任何中断的情况下工作,它是有效的。
#include <msp430fr4133.h> #include <driverlib.h> #include "main.h" #include <stdio.h> #include <stdlib.h> volatile unsigned char s1current, s2current; volatile unsigned char s1last, s2last; void main(void)<stdio.h>#include <stdlib.h> volatile unsigned <stdlb> s1current; s1current; s2fld w; s= wWDWDTWDT/WHOLD= ~WDT //禁用GPIO开机默认高阻抗模式 //要激活先前配置的端口设置 P1DIR = 0xFB;// WFP 1.0 引脚设置为输出,其余的为输入 P4DIIR |= BIT0;// WFP 4.0 引脚设置为输出,其余的为输入 P2REN |= BIT6;//为2.6 POPP2IN |= BIT6; //为WFP 2.6 P1REN选择上拉模式|= BIT2;//为WFP 1.2 P1IN启用内部上拉/下拉电阻器|= BIT2;//为WFP 1.2 P1OUT选择上拉模式= 0xEF;//打开LED P4OUT |= BIT0;//打开LED s1last = BIT2; s2it1; while last s1电流= P1IN; s2电流= P2IN; IF (((s1current & BIt2)== 0)&&(s1last & BIt2)== BIt2)//如果按下按钮S1 ... { P4OUT ^= BIT0; } 如果((s2current & BIT6)== 0)&&(s2last & BIT6)== BIT6)//如果按了按钮S2 ... { P1OUT >>=1; } s1last = s1current; s2last = s2current; _DELAY周期(1000); //延迟时间 }
中断代码中出现此问题的原因是什么???