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.

捕获单元中变量定义问题



"DSP28_DefaultIsr.c", line 555: warning: variable "f" was set but never used
下面是我的捕获单元的中断函数,分析程序之后觉得应该没问题的啊,但是总是出现说“f”被定义了却被使用,这是什么原因呢?以前也有遇到这类的问题,还请帮忙解决一下,非常感谢!

interrupt void CAPINT1_ISR(void)    // 捕获单元1中断
{
                 unsigned int temp;
         unsigned int capnum1;
         unsigned int capnum2;
         float f;
                 capnum1=EvaRegs.CAP1FIFO;
         capnum2=EvaRegs.CAP1FIFO;
            if(capnum2>capnum1)
               temp=capnum2-capnum1;
                else
                        temp=capnum2+(0xFFFF-capnum1);

                  f=2343750.0/(float)temp;                    //f=150MHZ/64temp=2343750.0/(float)temp
          PieCtrl.PIEACK.all=PIEACK_GROUP3;      //响应同组其他中断
            EvaRegs.EVAIFRC.bit.CAP1INT=1;        //清除中断标志位
            EINT;//开全局中断
         // 返回;
}

来自21ic论坛 TI DSP版块

  • Hi mangui,

    这个Warning是C2000的编译器对于你定义的变量'f'在程序中只被“赋值”但“未被使用”的一个警告。

    看了你的给出的代码,的确在你的代码中只有一种“赋值”语句

     f=2343750.0/(float)temp;                    //f=150MHZ/64temp=2343750.0/(float)temp

    除此之外,f没有被使用到。这里所谓“使用”,是指变量被用于计算、判断等运算,不包含“赋值”。

    这个警告对你的程序运行不会产生影响。

    Regards,

    Jay

  • 非常感谢你的回复,明白了