Page 1 of 1

Erratic timer operation

Posted: Mon Jan 15, 2018 11:32 am
by howard123
Hello all

I am having a problem with the timers on a PIC16F18854 in that there is an irregular behavior in the servicing of the associated ISR. This manifests as the ISR running sometimes as normal, sometimes as irregular and sometimes as not running at all. When it does run, the ISR is at the correct point in time, if this makes sense.

This is demonstrated in the ISR as output B2 and in the main loop as output B0.

I have associated this variable behavior as being a function of some minor things being placed in the main loop, as shown in my example. I have tested both TMR0 and TMR1 to have this condition and am guessing that the other timers might be affected in a similar way.

Many thanks
FC7.3.0.5 (the problem existed before this update)

Re: Erratic timer operation

Posted: Mon Jan 15, 2018 5:31 pm
by Benj
Hi Howard,

Hmm that's a strange one. B2 seems to work ok driven by the timer interrupt but B0 doesn't light up at all for me.

Looks like the problem lies in the TickGlobal macro and when the timer interrupt fires. If the timer fires just before the decision instruction in TickGlobal then B0 should light but it looks like we are regularly missing this window.

What specifically are you trying to do? maybe there is a better way.

Re: Erratic timer operation

Posted: Fri Jan 19, 2018 11:01 am
by howard123
Hi Ben

The code in main is mostly illustrative and not necessarily needed. I have subsequently made a main loop counter to derive time for this application and that is working fine so timers are no longer required.

On my hardware, the output within the IRS (B2) is erratic and is related in some way to the code in main. I have seen this on more than one prototype board.

Thanks this is resolved for me but may be useful for others to be made aware of this chip's timers.


Re: Erratic timer operation

Posted: Sat Jan 20, 2018 3:01 am
by Kenrix2
There is nothing wrong with the chip's timers. This is a Flowcode bug.