>---- Original Message -----
>From: Paul B. Webster VK2BZC <
paulb
KILLspamMIDCOAST.COM.AU>
>To: <
.....PICLISTKILLspam
.....MITVMA.MIT.EDU>
>Sent: Monday, October 18, 1999 11:17 PM
>Subject: Re: TMR0 Latency
>
>
>> Thomas Brandon wrote:
>>
>> > I am looking at a project requiring a very tight timing loop.
>>
>> If so, I'd avoid interrupts like the plague!
>>
>> > What delays are present in a TMR0 interrupt on overflow driven loop.
>> > The basic idea would be (assuming TMR0 overflow is the only enabled
>> > interrupt):
>>
>> The delays are:
>> 1} an extra cycle if the presently executed instruction modifies PC.
>> 2} Interrupt latency - an interrupt modifies PC too!
>> 3} context saving.
>>
>> > ORG 0x004
>> > MOVF delay
>> > SUBLW int_latency
>> > MOVWF TMR0
>>
>> No context saving! Not workable. Need to save STATUS, W, maybe other
>> things. May need to clear bank select to access TMR0.
>
>That's purposeful, there's too much to do in the given time to waste 6inst.
>saving context, everything would happen in the TMR0 interrupt to prevent
>context saves, sorry for not making clear.
>
>> > where delay is the number of cycles (if prescaler = 1:1) and
>> > int_latency is the total latency of the interrupt occuring and of
>> > setting TMR0. In this case int_latency would be 3 inst (MOVF-MOVWF) +
>> > the delay for the interupt to fire + the delay for the setting of
>> > TMR0. From reading the MChip docs I think that there is a 4 inst delay
>> > for the interrupt to fire and actually execute 0x004 for real, and a 2
>> > inst delay for the update of TMR0 to kick in. Hence I would set
>> > int_latency to 4 + 2 + 3 = 9inst. Is this correct?
>>
>> Sounds plausible. Honestly, I would take that as an indication to
>> forget using an interrupt for this purpose.
>Not so much interrupts, just PIC interrupts. Scenix interrupts with
>"determnistic jitter free 60ns int., 100ns ext" interrupts with hardware
>context saves would be much more acceptable.
>
>> > Is there any jitter in the internal interrupt handling?
>>
>> Yes, depends on whether it happens to hit a branch instruction.
>That could be a problem. I don't need to do anything in the main code, but
>to infinitely loop I need lots of jumps (well, just one, but it's executed a
>lot), so there would be a lot of 2 cycle inst.'s.
>
>> It sounds like you plan to enter a tight loop and use interrupts to
>> do your timing. That sounds crazy to me. Unless you context save, it
>> will be very difficult to avoid crashing the loop badly. The only
>> conditional you could use within the loop is BTFSx. The loop couldn't
>> do any useful processing anyway.