1 Reply Latest reply on Aug 18, 2017 12:55 PM by ted_1467596

    Code in main.c reads from SPI but isr_1.c doesn't

    ted_1467596

      I will upload my project in the next post but it's giving me a problem in that code that works in main.c doesn't work in isr_1.c, specifically the code starting at line 198 in main.c

       

              response = LIS3DH_GetAccAxesRaw(&data); // TM read and print Raw Accel data

              if(response==1){

                  //print data values

                  sprintf(strMsg1, "Xx=%6d Yy=%6d Zz=%6d \r\n", (data.AXIS_X >> 6), (data.AXIS_Y >> 6), (data.AXIS_Z >> 6) );

                  SCB_1_UartPutString(strMsg1);

              }

              sprintf(strMsg1, "X=%6d Y=%6d Z=%6d \r\n", (rawAccel[0][0]), (rawAccel[1][0]), (rawAccel[2][0]));

       

      Works with data read out like Xx= -12  Yy= 7  Zz= 244

       

      but the same code at ine 185 in isr_1.c is supposed to populate the array variable rawAccel[0][0]..[2][0]

       

                  response = LIS3DH_GetAccAxesRaw(&data); // TM read and store Raw Accel data

                  if(response==1){

                      LED_2_Write(1);

                      rawAccel[0][0] = data.AXIS_X;

                      rawAccel[1][0] = data.AXIS_Y;

                      rawAccel[2][0] = data.AXIS_Z;

                  }

       

      which is supposed to be printed out by line 204 (the last line in the code above) but it doesn't produce any data, the printed line is always all zeros.  The raw accelerometer data is supposed to be 12 bits left justified stored in a int16.  I've proved that, in the ISR code, I'm getting a 1 for the response because LED2 lights up.  This may be the way I'm trying to share variables across all the files.

       

      I'd appreciate any guidance you guys may have.