小编Vis*_*al 的帖子

在高编译器优化模式下在msp430中定时使用

我在MSP430中使用了具有高编译器优化的定时器A,但发现我的定时器代码在使用高编译器优化时失败.如果没有使用优化,代码工作正常.

此代码用于实现1 ms计时器滴答.timeOutCNT在中断时增加.

以下是代码,

        //Disable interrupt and clear CCR0
        TIMER_A_TACTL = TIMER_A_TASSEL |                        // set the clock source as SMCLK
            TIMER_A_ID |                            // set the divider to 8
            TACLR |                                 // clear the timer
            MC_1;                   // continuous mode
        TIMER_A_TACTL &= ~TIMER_A_TAIE;                         // timer interrupt disabled
        TIMER_A_TACTL &= 0;                             // timer interrupt flag disabled

        CCTL0 = CCIE;                                   // CCR0 interrupt enabled
        CCR0 = 500;
        TIMER_A_TACTL &= TIMER_A_TAIE;              //enable timer interrupt
        TIMER_A_TACTL &= TIMER_A_TAIFG;             //enable timer interrupt
        TACTL = TIMER_A_TASSEL + MC_1 …
Run Code Online (Sandbox Code Playgroud)

c timer msp430

0
推荐指数
1
解决办法
1555
查看次数

标签 统计

c ×1

msp430 ×1

timer ×1