TA的每日心情 | 开心 2015-5-11 08:21 |
---|
签到天数: 61 天 连续签到: 1 天 [LV.6]常住居民II
|
本帖最后由 netel 于 2013-8-7 14:52 编辑
- #include "msp430.h"
- const unsigned char curve[] = {
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 2, 2, 2, 2, 2,
- 2, 2, 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 5, 5, 5,
- 5, 6, 6, 6, 6, 7, 7, 7,
- 8, 8, 8, 8, 9, 9, 9, 10,
- 10, 10, 11, 11, 11, 12, 12, 13,
- 13, 13, 14, 14, 15, 15, 15, 16,
- 16, 17, 17, 18, 18, 18, 19, 19,
- 20, 20, 21, 21, 22, 22, 23, 23,
- 24, 24, 25, 25, 26, 26, 27, 27,
- 28, 29, 29, 30, 30, 31, 31, 32,
- 33, 33, 34, 34, 35, 36, 36, 37,
- 38, 38, 39, 39, 40, 41, 41, 42,
- 43, 43, 44, 45, 46, 46, 47, 48,
- 48, 49, 50, 50, 51, 52, 53, 53,
- 54, 55, 56, 56, 57, 58, 59, 59,
- 60, 61, 62, 62, 63, 64, 65, 66,
- 66, 67, 68, 69, 70, 70, 71, 72,
- 73, 74, 75, 75, 76, 77, 78, 79,
- 80, 80, 81, 82, 83, 84, 85, 86,
- 87, 87, 88, 89, 90, 91, 92, 93,
- 94, 95, 95, 96, 97, 98, 99, 100,
- 101, 102, 103, 104, 105, 106, 106, 107,
- 108, 109, 110, 111, 112, 113, 114, 115,
- 116, 117, 118, 119, 120, 121, 122, 122,
- 123, 124, 125, 126, 127, 128, 129, 130,
- 131, 132, 133, 134, 135, 136, 137, 138,
- 139, 140, 141, 142, 143, 144, 145, 146,
- 147, 148, 149, 150, 151, 152, 153, 154,
- 155, 156
- };
- int pos = 0;
- int main(void)
- {
- WDTCTL = WDTPW + WDTHOLD;
- DCOCTL= 0;
- BCSCTL1= CALBC1_1MHZ;
- DCOCTL= CALDCO_1MHZ;
- BCSCTL2 |= DIVS_3;
- P1DIR |= BIT6 | BIT0;
- P1OUT ^= BIT0;
- P1SEL |= BIT6;
- TACCR0 = 625;
- TACTL = TASSEL_2 | MC_1;
- TACCTL1 = OUTMOD_7 | CCIE;
- TACCR1 = 0;
- __low_power_mode_0();
- return 0;
- }
- #pragma vector=TIMER0_A1_VECTOR
- __interrupt void t0a1_isr(void)
- {
- int ccr1 = 1;
-
- TACCTL1 &= ~CCIFG;
- if (pos < 500) {
- ccr1 = curve[pos++ >> 1];
- } else if (pos < 1000) {
- ccr1 = curve[(999 - pos++) >> 1];
- } else {
- pos = 0;
- P1OUT ^= BIT0;
- }
- if(P1IN&BIT0) {
- for(int i = 3000;i>0;i--);
- P1OUT ^= BIT0;
- } else {
- while (TAR <= ccr1);
- TACCR1 = ccr1;
- }
- }
复制代码 別的就不用說了, 代碼在上面, 雖然有部分代碼不是我實現的, 但也有我自己加的部分在內。
忘記說了, 是iar版本, ccs的需要改中斷服務的定義方法。
|
|