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

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
TeMa_1467596
Level 5
Level 5
5 sign-ins 5 likes given First like received

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.

0 Likes
1 Reply
lock attach
Attachments are accessible only for community members.
TeMa_1467596
Level 5
Level 5
5 sign-ins 5 likes given First like received

Code as promised

0 Likes