This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

编译器提示IDATA 溢出



求解,在使用time3 PWM输出时,编译器debug时一直提示idata溢出

  • 寄存器设置时,赋值有错误吗?

  • 寄存器配置应该不会有问题,代码如下:

    /* Setup TIMER3 PWM at alternate location 2 */
    PERCFG |= 0x20; // TIME3 at location 2
    P1SEL |= 0x40; // Peripheral function on TIMER3 (P1_6 P1_7)
    P2SEL |= 0x20; // Give priority to TIMER3 over USART 1 for P1_6 P1_7 pins.


    //set the time ticks to 32M , CLKCONCMD[5:3]
    CLKCONCMD &= ~0x08;
    CLKCONCMD &= ~0x10;
    CLKCONCMD &= ~0x20;
    //set the Prescaler divider to 128
    T3CTL |= 0x80;
    T3CTL |= 0x40;
    T3CTL |= 0x20;

    //set the timer3 mode
    T3CTL |= 0x03; //up/down

    //set the time3 channel0 mode
    T3CCTL0 |= 0x04; //compare mode

    T3CCTL0 |= 0x20; //clear output on compare_up,set on 0
    T3CCTL0 &= ~0x10;
    T3CCTL0 &= ~0x08;

    //clear counter
    T3CTL |= 0x04;

    //set the compare value
    T3CC0 = 0x40;

    //set the interrupt
    T3CTL |= 0x08; //overflow interrupt mask
    T3CCTL0 |= 0x40; //channel 0 interrupt mask

    IEN0 |= 0x80; //enable interrupt
    IEN1 |= 0x08; //timer3 interrupt enable

    // //start the pwm
    T3CTL |= 0x10;

    还有如果我在上面的代码后面加while(1)pwm波形输出正常,但是去掉while(1)后,系统跑起来后看波形根本没按设定的速率输出,一点规律没有