Hello=20 I'm a student in computer science in Belgium and it is my last year of st= udy.=20 My thesis consists in realising an automatic horizon for a camera which=20 is in a remotily controled helicopter (www.flying-cam.com).=20 I studied Intel assembly at school, but I've never learned how to=20 program a microcontroler. So I looked for help and tutorials on the=20 Internet. I'm working with PIC's since only two months.=20 I'm currently coding my automatic horizon software on a PIC16F877=20 and I have some real time problems. I'll try explain that clearly.=20 My PIC must measure a PWM signal in input, then it computes this value=20 with values from captors (accelerometer and gyro), finaly it outputs the=20 result in the form of an other PWM signal.=20 I must measure the input signal with 1 =B5s precision.=20 I use the RBIF interrupt to detect the edges of the input signal,=20 timer 0 to measure the lenght of the signal. I use timer 1 with the CPP=20 to output the result signal.=20 TMR2 is used to generate the frequency of the output=20 signal. The problem is that RBI interrupt can occur while=20 executing the tmr2 interrupt code, and the measure of=20 the input signal will be faulty because the RBI does not=20 react immediately. So I've used nested=20 interrupts with a software stack (I found this method in the piclist=20 source code library), but there is always a=20 part of the code where interrupts are disabled.=20 [Update] I use the two CPP to output signals. These signals are used to make spinning a motor. The motor have to spin in the two ways, so when the motor have to spin left, I use CPP1, and when it have to spin right, I use CPP2 Does anybody has an idea to make this measure accurately ?=20 Thanks a lot for your help.=20 Laurent=20 NB : I'm french speaking, so I hope I haven't made too=20 much mistakes in English=20 -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads