Quote Originally Posted by Kaya Onur View Post
Hi everybody,
I want to obtain servo control pulses. 50Hz (1520us center puls) using a 16F88 TMR0 interrupt. Running 8MHz (therefore 2MHz from FOSC/4) with 1/256 prescaler.

In the interrupt handler right after entry, I preload the TMR0 counter then PULSOUT. It is a very basic code.

It seems that the counter pauses during the PULSOUT because the outcoming signal's period is lengthened by the puls duration.

I tried different TMR0 values. Some does work fine some doesn't. By working fine I mean that the outcoming signal's period (therefore frequency) doesn't change with regard to puls duration.

Any idea?

Code for the interrupt handler:

DISABLE
INTERRUPT_HANDLER:
TMR0=160 'Tried different values here. Some work fine some doesn't.

PULSOUT SERVO, Duration 'SERVO is a SYMBOL for PORTA.2
LOW SERVO 'Just a precaution...

INTCON.2=0 'Interrupt flag cleared.
RESUME
ENABLE
If the TMR is disabled when entering the INT, then it is not counting. Therefore thr duration of PULSOUT will change the timing.

Move PULSOUT to your main loop. Set a flag in your INT. Then in your main loop, if the flag is set, execute PULSOUT and clear the flag.