Quadcopter project-need solution for my issue

I am making a quadcopter with my mcu called Hifive1 , i am facing an issue for a long time , i am unable to find the cause and solution for the issue.

In my main loop i call functions like reading receiver's input, gyro values, pid calculation and finally
esc outputs.

I am using arduino pro mini as a pwm to ppm converter so the output ppm pin go into the hifive1 as a rising interrupt pin.

The problem is when the sticks are at the center the values should be 1500(+/-2) but here the values are more unstable/noisy/jittery ranging from 1467-1529

i checked with gyro sensor communication fortunately it is good.

In my main loop code if i comment some lines randomly the signals are proper it is so strange !
why what is the reason
here i share my code

when the length of the code is big it gets affected! but technically what is the problem?

In my main loop code if i comment some lines randomly the signals are proper it is so strange !

Ok, but please tell us which lines you did this to, so we can reproduce the same results. This kind of thing is usually a symptom of running out of memory. Commenting out any piece of code will change the memory usage enough to shift the corruption caused by overwriting a different piece of memory.

Your code is hard to read with inconsistent indenting. Use the auto format function in Arduino. It is very good. If it appears to scramble your code then your code was wrong.

The one thing that stands out on my first read through is you are using Serial.print() inside the ISR. Take all of that out. You should never attempt to print while interrupts are disabled.

Thanks for your immediate response.

i have 4 methods of ppm decoding otherwise ISR's , in that code i used 3rd method it seems and i forgot to comment that serial print inside the isr ,it has to be pasted in the main loop instead.

and the 4th method is in the library form.

I tried all but getting the same problem.

coming to your question,

Example :if i comment from(int the main loop)

gyro_roll_input = (gyro_roll_input * 0.7) + (((float)gyro_roll / 65.5) * 0.3); //Gyro pid input is deg/sec.
gyro_pitch_input = (gyro_pitch_input * 0.7) + (((float)gyro_pitch / 65.5) * 0.3);//Gyro pid input is deg/sec.....................................................

UNTILL ending brace of if (start == 2)

i am getting expected result ie 1500+-2

otherwise if i comment

Accelerometer angle calculations ,
setting dead bands sections,
codes after lowExit=0;

i will get those expected values.

And i have also checked by commenting lines one by one ,as the code length decreases the values are
meeting the stable conditioin.

pid calculations are just contains arithmetic operations ! it is very strange to me.

i checked with pin connections , communication between the sensors and receivers as well everything is fine.

Use the auto format function in Arduino.

Sure, i will do it hereafter.

Any solutions?