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.

syntax error or unknown identifier for Sensor Controller Studio make program



hi Ti professor,

software:sensor controller studio 2.3.0.684

As shown as the picture, In sensor controller studio I add a for() but the error occur. It is uniamginable to use sensor controller studio. There are always syntax error or unknown identifier when I use while() or for().

  • Try to define "U16 n;" outside the for-loop.
  • The U16 definition is ok, try to add {} as shown below:

    for (U16 n = 0; n < 19; n++) {
        n = n + 1;
    }

  • hi TER,
    I have tried to add{} but error occur again. I suspect that if the compiler has bugs. Have you never had such a problem?
  • I tested by adding the lines I posted in the LED blinker project and I got an error if I didn't use {} and no error if I added them (as I posted)
  • when the parameter use n,it no error but when i change n to j,the error occur.

  • Can you post complete code section?
  • macro SPI_Write_TwoBytes(reg_addr, reg_value) {
        U16 addr_value;
        addr_value= (reg_addr<<8)|reg_value;
        spiCfg(SPI_POL1_PHA1,1);
        spiBegin(AUXIO_SPI_CSN_NCS);
        spiTx16bit(addr_value);
        spiEnd(AUXIO_SPI_CSN_NCS);
    }
    
    macro SPI_Read_OneByte(reg_addr, reg_value) {
        U16 reg_addr1;
        U16 reg_value1;
        reg_addr1=0x80|reg_addr;
        spiCfg(SPI_POL1_PHA1,1);
        spiBegin(AUXIO_SPI_CSN_NCS);
        spiTx8bit(reg_addr1);
        spiRx8bit(reg_value1);
        spiEnd(AUXIO_SPI_CSN_NCS);
        reg_value =reg_value1;
    }
    
    //macro SPI_Read_Bytes(reg_addr, *reg_value, len) {
    //    U16 reg_addr1;
    //    U16 reg_value1;
    //    reg_addr1=0x80|reg_addr;
    //    spiCfg(SPI_POL1_PHA1,1);
    //    spiBegin(AUXIO_SPI_CSN_NCS);
    //    spiTx8bit(reg_addr1);
    //    for (U16 n = 0; n < len; n++) {
    //        spiRx8bit(reg_value1);
    //      }
    //      *reg_value =reg_value1;
    //    spiEnd(AUXIO_SPI_CSN_NCS);
    //}
    macro delay(n){
        S16 i;
        i=n;
        while (i >= 0) {
            i -= 1;
        }
    }
    
    
    /////////wake on motion setup//////////////////////////////
    //U16 womint=0;
    //gpioGetInputValue(AUXIO_I_WOM_INT;womint);
    //output.int = womint;
    output.ReadOk = 0;
    //SPI_Read_OneByte(INT_STATUS,output.AcceY );
    //if(womint == 1) {
    // Set up the first interrupt trigger
    // evhSetupGpioTrigger(0, AUXIO_I_WOM_INT, 1, EVH_GPIO_TRIG_ON_EDGE);
    // enable gyro and acce
    // SPI_Write_TwoBytes(PWR_MGMT_2, 0x00);
    //  delay(100);
    SPI_Read_OneByte(FIFO_WM_INT_STATUS,output.ReadOk );
    //   delay(10);
    if(output.ReadOk == 0x40){
        U16 reg_addr1;
        U16 reg_value1;
        reg_addr1=0x80|FIFO_R_W;
        spiCfg(SPI_POL1_PHA1,1);
        spiBegin(AUXIO_SPI_CSN_NCS);
        spiTx8bit(reg_addr1);
        //for (U16 n = 0; n < FIFO_LEN; n++) {
        //    spiRx16bit(output.DATA[n]);
        //}
        for (U16 j = 0; j < FIFO_LEN; j++) {
            spiRx16bit(output.DATA[j]);
        }
        spiEnd(AUXIO_SPI_CSN_NCS);
    }
    //    SPI_Read_OneByte(INT_STATUS,output.AcceX );
    //S16 GyroX=0;
    //S16 GyroY=0;
    //S16 GyroZ=0;
    //S16 AcceX=0;
    //S16 AcceY=0;
    //S16 AcceZ=0;
    //SPI_Read_OneByte(INT_STATUS,output.ReadOk );
    //delay(10);
    //if(output.ReadOk==0x01){
    //////////////////////////acce/////////////////////////////////////
    //    SPI_Read_OneByte(ACCEL_XOUT_H,AcceX );
    //    delay(10);
    //    SPI_Read_OneByte(ACCEL_XOUT_L,output.AcceX );
    //    delay(10);
    //    output.AcceX=output.AcceX|(AcceX<<8);
    
    //    SPI_Read_OneByte(ACCEL_YOUT_H,AcceY );
    //    delay(10);
    //    SPI_Read_OneByte(ACCEL_YOUT_L,output.AcceY );
    //    delay(10);
    //    output.AcceY=output.AcceY|(AcceY<<8);
    
    //    SPI_Read_OneByte(ACCEL_ZOUT_H,AcceZ );
    //    delay(10);
    //    SPI_Read_OneByte(ACCEL_ZOUT_L,output.AcceZ );
    //    delay(10);
    //    output.AcceZ=output.AcceZ|(AcceZ<<8);
    ////////////////////////////////gyro/////////////////////////////////////
    //    SPI_Read_OneByte(GYRO_XOUT_H,GyroX );
    //    delay(10);
    //    SPI_Read_OneByte(GYRO_XOUT_L,output.GyroX );
    //    delay(10);
    //    output.GyroX=output.GyroX|(GyroX<<8);
    
    //    SPI_Read_OneByte(GYRO_YOUT_H,GyroY );
    //    delay(10);
    //    SPI_Read_OneByte(GYRO_YOUT_L,output.GyroY );
    //    delay(10);
    //    output.GyroY=output.GyroY|(GyroY<<8);
    
    //    SPI_Read_OneByte(GYRO_ZOUT_H,GyroZ );
    //    delay(10);
    //    SPI_Read_OneByte(GYRO_ZOUT_L,output.GyroZ );
    //    delay(10);
    //    output.GyroZ=output.GyroZ|(GyroZ<<8);
    //}
    // }
    //}
    // Schedule the next execution
    fwScheduleTask(1);

  • From the documentation on for loops in Sensor Controller Studio:
    "The for-loop is bound to use n as counter variable"