#include <msp430g2231.h>
unsigned int a=0,p=1;
void delay(int x)
{
int i,j;
for(i=0;i<=x;i++)
for(j=0;j<=x;j++);
}
void initial()
{
DCOCTL=0x30; //15.25MHZ
BCSCTL1=0x0f;
BCSCTL2=0x00;//BCSCTL2=SELM_0;
_BIS_SR(OSCOFF);
}
#pragma vector=PORT1_VECTOR
__interrupt void port1(void)
{
_EINT();
delay(20);
if(P1IFG&BIT3)
{
CCTL0=CCIE;
TACCR0=10000;
TACTL=MC_1+TASSEL_2+TAIE;
}
P1IFG=0;
return;
}
#pragma vector=TIMERA0_VECTOR
__interrupt void timera(void)
{
a++;
if(a==85)
{
a=0;
P1OUT^=BIT0;
return;
}
}
void main()
{
WDTCTL=WDTPW+WDTHOLD;
initial();
P1IE|=BIT3;
P1IES|=BIT3;
_EINT();
P1DIR|=BIT0;
LED0ON;
LPM0;
while(1);
}
此帖出自
小平头技术问答
一周热门 更多>