Reflect or lighten the LED during the button press (MSP430 Applications C ++)
#include <msp430.h>
unsigned int bsayac=0;
void main(void) {
WDTCTL = WDTPW | WDTHOLD; // Watchdog timer OFF
BCSCTL1 = CALBC1_1MHZ; // Ocilator is 1MHz .
DCOCTL = CALDCO_1MHZ; // Ocilator is 1MHz.
P1DIR =0x07;
P1OUT=0x00;
TACCTL0 =CCIE;
// CCR0 interrup is ON // CCR0 set 1000 ms
TACTL = TASSEL_1 + MC_1; //
_BIS_SR(GIE);
while (1){
while(!(P1IN & 0x08)) {
++bsayac;
TACCR0 = (bsayac*5.05);
}
bsayac=0;
}
}
#pragma vector=TIMER0_A0_VECTOR // Timer0_A0 interrupt vector
__interrupt void Timer_A (void)
{
P1OUT ^=0x07;
// reverse Port1.1
}
Yorumlar
Yorum Gönder