I am coming from the 68hc world into the pic world. One of my old tricks was to use a delay loop to operate a pin to drive an RC servo. Worked pretty good. I tried the same trick on the PIC877a and it is completely unstable. The wave form jitters and varies in duration. Power supply is a bench top supply (very clean). I am using an 8mhz crystal and I believe I have turned off the interrupts. I am clueless.
BrianThor
No schematic
No code
No understanding
No sense
To drive servos you better use PWM module. And you better skip rotten pic and avr and start discover the power of ARM!)))
It is cheaper and faster.
Treat that as an opinion, if it was true, Microchip wouldn't be one of the Worlds biggest MCU manufacturers.... and they use ARM cores in some PIC products anyway!
In principle there is no reason why an 16F877A can not be used to replace a 68HC11 provided the code is re-written properly. The PIC already has a hardware PWM module which can generate the RC servo signal without using delay loops, it makes operation far easier because you just write new values to the PWM module to set the frequency and pulse width and the harware does the rest. It means your code can carry on doing something else while the RC signal is still being produced.
Obviously we need to see your code to be sure but the description you give suggests you have the watchdog timer running and it is cyclically resetting the PIC as you try to produce the output waveform. If I'm right, you can either extend the watchdog period (assuming you reset it within the program) of disable it altogether. Disabling as a first step will confirm if my diagnosis is correct or not.
It is allways a bad idea, unless you're planning to do nothing else with your 40-pin 16F877 microcontroller than making this control. Even if you were working with a device without built-in PWM modules, you could do that without closed loop delays, but with timer interrupts.