|
#include
void P1_IODect();
void P13_Onclick();
void GPIO_init();
volatile unsigned int n,m,i=0;
unsigned const PWMperiod=15000;
void main(void)
{ WDTCTL=WDTPW+WDTHOLD;
int i=0;
i=i+1;
GPIO_init();
DCOCTL=0x00;
DCOCTL=CALDCO_1MHZ;
BCSCTL1=CALBC1_1MHZ;
TACTL=TASSEL_2+MC_1;
TACCR0=PWMperiod;
TACCTL1=OUTMOD_7;
_EINT();
LPM0;
}
void GPIO_init()
{
P1DIR|=BIT6;
P1SEL|=BIT6;
P1REN|=BIT3;
P1OUT|=BIT3;
P1DIR&=~BIT3;
P1IES|=BIT3;
P1IE|=BIT3;
}
#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR(void)
{
P1_IODect();
P1IFG=0;
}
void P1_IODect()
{
unsigned int Push_Key=0;
Push_Key=P1IFG&(~P1DIR);
__delay_cycles(10000);
if((P1IN&Push_Key)==0)
{
switch(Push_Key)
{
case BIT3: P13_Onclick(); i++; break;
default: break;
}
}
}
void P13_Onclick()
{
if(i/2==1)
{
for(n=0;n
{
TACCR1=n;
}
}
if(i/2==1)
{
for(m=PWMperiod;m>0;m--)
{
TACCR1=m;
}
}
}
|
|