I'm working with a PIC18F452 with a 20 MHz extrenal clock, writing a program with PBP 2.46
I'm generating pulses using PORTC.5 in the interrupt routine to drive a stepper motor.
I'm measuring the output pulse on pin 28 (portc.5) with an oscilloscope.
Variable PRESCALER is used to load TMR1

if PRESCALER = 65430 output frequency is 19.85 KHz
if PRESCALER = 65431 output frequency is 19.85 KHz
if PRESCALER = 65432 output frequency is 19.85 KHz
if PRESCALER = 65433 output frequency is 20.83 KHz !!!!!!!!!!!!!!!!!!!!!!!!!!
if PRESCALER = 65434 output frequency is 20.77 KHz
if PRESCALER = 65435 output frequency is 20.77 KHz
if PRESCALER = 65436 output frequency is 20.83 KHz
if PRESCALER = 65437 output frequency is 20.83 KHz
if PRESCALER = 65438 output frequency is 21.74 KHz !!!!!!!!!!!!!!!!
if PRESCALER = 65439 output frequency is 21.74 KHz
if PRESCALER = 65440 output frequency is 21.82 KHz

Can someone please explain me why I get 1 KHz frequency gaps ? Is this normal?

Below part of my code:

PRESCALER VAR WORD
PRESCALERL VAR PRESCALER.byte0
PRESCALERH VAR PRESCALER.byte1
T1CON = %00010100 'TIMER1 PRESCALER 1:2, TIMER , CLOCK INTERNO (F/4), STOP TIMER1 &&&

miint:
IF PIR1.0 = 1 THEN
T1CON.0 = 0
PORTC.5 = 0 'STEP pulse
TMR1H = PRESCALERH
TMR1L = PRESCALERL
PORTC.5 = 1 'PULSO DE STEP
ENDIF
T1CON.0 = 1
PIR1.0 = 0
Resume ' retorna al programa principal


Norberto Karpovich