我按照clogord兄弟的呼吸灯改编的,呼吸效果不怎么好啊,感觉要死的样子
[复制链接]
#include<msp430g2452.h> volatile unsigned char flag=0; void BreathLED() { P1SEL =BIT6; P1DIR = BIT6; P1OUT=0; TACTL = TASSEL_1 + MC_1 ; TACCTL1 = OUTMOD_3 ; TACCTL0 = CCIE; CCR0 =328; CCR1 =327; //0% pwm TACTL |=TACLR; _EINT(); } int main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; BreathLED(); LPM0; return 0; }
#pragma vector=TIMER0_A0_VECTOR __interrupt void CountTimes() { static int Times; Times++; if(flag) CCR1=Times; else CCR1=400-Times; if(Times==400) {Times=0;flag=!flag;} }
|