#include #include void delay_ms(uint16_t ms) { while (ms--) __delay_cycles(1000); } void delay(int16_t count) { while (count--) __nop(); } const int STEP = 5, COUNT = 500; int main() { int16_t start, step, end, i; // Disable watchdog WDTCTL = WDTPW | WDTHOLD; // 1MHz internal timer BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; // P2 (XOUT/XIN) as GPIO P2SEL = 0x00; P1OUT = 0x00; P1DIR = 0x01; start = 0; end = COUNT; step = STEP; /*while (1) { for (i = start; i != end; i += step) { P1OUT = 0x01; delay(i); P1OUT = 0x00; delay(COUNT - i); } start = COUNT - start; end = COUNT - end; step = -step; if (step > 0) delay_ms(500); }*/ int16_t freq, afreq; TACTL = TASSEL1 | TACLR; P1SEL |= 0x04; // TA1 on P1.2 P1DIR |= 0x04; // P1.2 output TACCTL0 &= ~CCIE; TACCTL1 = OUTMOD_7; TACTL |= MC0; //TACCR0 = 2272; //TACCR1 = 2272 / 2; while (1) { for (freq = -1000; freq < 1000; freq += 10) { afreq = 1000 + (freq < 0 ? -freq : freq); TACCR0 = afreq; TACCR1 = afreq / 2; delay_ms(5); } } return 0; }