#include <msp430.h>#define MCLK_C (1)#define Delay_us(n) __delay_cycles(n*MCLK_C)#define Delay_ms(n) __delay_cycles(n*(1000L)*MCLK_C)int b=1;int main(void){ WDTCTL = WDTPW+WDTHOLD; P1DIR|=BIT6; P1SEL|=BIT6; P1REN|=BIT3; P1OUT|=BIT3; P1IE|=BIT3; P1IES=BIT3; P1IFG&=~BIT3; CCR0=1000; CCTL1=OUTMOD_7; CCR1=0; TACTL=TASSEL_2+MC_1+TACLR; _EINT(); while(1) { if(b==1) { CCR1+=5; Delay_ms(10); if(CCR1>=1000&b==1) { while(b==1) { CCR1-=5; Delay_ms(10); if(CCR1<=0) { CCR1=0; break; } } } } if(b==0) { CCR1=0; while(b==0); } } }
#pragma vector=PORT1_VECTOR__interrupt void Port_1(void){ if(b==1) { b=0; P1IFG&=~BIT3; } if(b==0) { b=1; P1IFG&=~BIT3; }}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>