|
MSP430单片机调PMW程序: #include"msp430G2553.h" #define uint unsigned int
uint Fre,temp1=50;
void delay( int ms)
{
int i;
while(ms--)
for(i=0;i<120;i++);
}
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
DCOCTL=CALDCO_16MHZ;BCSCTL1 = CALBC1_16MHZ;
BCSCTL2 |=SELM_1+DIVM_2;
P1DIR &=~BIT3;
P1REN |=BIT3;
P1OUT |=BIT3;
P1IE |=BIT3;
P1IES |=BIT3;
P1DIR |=BIT0+BIT6;
P1OUT &=~BIT6;
P1OUT |=BIT0;
_EINT();
while(1)
{
P1OUT ^=(BIT0);
delay(temp1);
}
}
#pragma vector=PORT1_VECTOR
__interrupt void PORTP13(void)
{
uint temp,pushkey=0;
pushkey=BIT3 & (~P1DIR);
__delay_cycles(10000);
temp=P1IN;
if((~temp) & BIT3==pushkey)
{
Fre++;
temp1 =temp1+100;
}
P1IFG &=~BIT3;
}
|
|