TI中文支持网
TI专业的中文技术问题搜集分享网站

如何在Sensor controller studio中编写for循环函数?

左边为代码,右边为编译对应行提示的错误:

//排序

for( i = 1; i < AD_SAMP_COUNT; i++){                                //compiling : Syntax error or unknown identifier(s)

      for( j = 0; j < i; j++){                                                       //compiling : Syntax error or unknown identifier(s)

if(adcValueBuff[i] < adcValueBuff[j]){

temp = adcValueBuff[i];

         adcValueBuff[i] = adcValueBuff[j];              //compiling : Syntax error or unknown identifier(s)

 adcValueBuff[j] = temp;                               //compiling : Syntax error or unknown identifier(s)

          }

      }                                   //compiling : Found ‘}’without valid corresponding ‘if/else/for/while(…){’

}                                         //compiling : Found ‘}’without valid corresponding ‘if/else/for/while(…){’

 

//滤波算法:去除高低,剩余值求平均

for(i=1;i<(AD_SAMP_COUNT-1);i++){                  //compiling : Syntax error or unknown identifier(s)

      adcValue = adcValue + adcValueBuff[i];

}                                                                  //compiling : Found ‘}’without valid corresponding ‘if/else/for/while(…){’

Viki Shi:

在SCS里面使用for 循环请注意:
"The for-loop is bound to use n as counter variable"

You must use the U16 n as index variable as described in the Task Code Language Reference:

The variable n is special:

It is always stored in the R0 register
It is used for data structure array indexing. No other variables can be used for this purpose.
It is used as counter variable in for-loops. No other variables can be used for this purpose.

user6315808:

回复 Viki Shi:

意思是说不可以“在for循环里,再嵌套第二层for循环”?如果可以,如何编写程序?谢谢

Viki Shi:

回复 user6315808:

意思是说在for 循环里面只能用n作为计数器变量,更详细的信息请查看我之前发的文档

user6315808:

回复 Viki Shi:

好的,谢谢

赞(0)
未经允许不得转载:TI中文支持网 » 如何在Sensor controller studio中编写for循环函数?
分享到: 更多 (0)