Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: Program skipping subroutines and infinite loops sometimes.

$
0
0
Hi, I made a program that reads data from an MPU6050 and also has a timer interrupt to move some motors. However some of my Calculation functions are never being called and even when I step through the program it just goes right past them. I am also experiencing infinite loops in for statements that are larger than 1000; Does a interrupt subroutine destroy my local variable stack and it get's reinitialized when it returns? volatile unsigned int count = 0; volatile unsigned int count2 = 0; P8OUT ^= BIT2; P4OUT ^= BIT0; while(count<1000){ count++; P8OUT ^= BIT1; P4OUT ^= BIT3; __delay_cycles(100); P8OUT ^= BIT1; P4OUT ^= BIT3; __delay_cycles(100); } P8OUT ^= BIT2; P4OUT ^= BIT0; while(count2 < 1000) { P8OUT ^= BIT1; P4OUT ^= BIT3; __delay_cycles(1000); P8OUT ^= BIT1; P4OUT ^= BIT3; __delay_cycles(1000); count2 = count2 + 1; } } This is another bizarre area in my code that I am unsure of what is happening void DERIVATIVE_CALCX(); void INTEGRAL_CALCX(); void positionCalc(); are all being skipped. void BYTES_TO_INT() { if(LOCATION_LOOP ==20) { LOCATION_LOOP = 0; } IMU_DATA[LOCATION_LOOP].xAccel = RXData[0] << 8 | RXData[1]; IMU_DATA[LOCATION_LOOP].yAccel = RXData[2] << 8 | RXData[3]; IMU_DATA[LOCATION_LOOP].zAccel = RXData[4] << 8 | RXData[5]; IMU_DATA[LOCATION_LOOP].xRot = RXData[6] << 8 | RXData[7]; IMU_DATA[LOCATION_LOOP].yRot = RXData[8] << 8 | RXData[9]; IMU_DATA[LOCATION_LOOP].zRot = RXData[10] << 8 | RXData[11]; void DERIVATIVE_CALCX(); void INTEGRAL_CALCX(); void positionCalc(); int i = 0; LOCATION_LOOP ++; for(i = 0;i<14;i++); { RXData[i] = 0; } }

Viewing all articles
Browse latest Browse all 62309

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>