Erratic timer operation

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

howard123
Posts: 66
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 25 times
Been thanked: 27 times
Contact:

Erratic timer operation

Postby howard123 » Mon Jan 15, 2018 11:32 am

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
Howard
FC7.3.0.5 (the problem existed before this update)
Attachments
Timer test.fcfx
(10.56 KiB) Downloaded 40 times

User avatar
Benj
Matrix Staff
Posts: 14313
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4405 times
Been thanked: 4128 times
Contact:

Re: Erratic timer operation

Postby Benj » Mon Jan 15, 2018 5:31 pm

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.

howard123
Posts: 66
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 25 times
Been thanked: 27 times
Contact:

Re: Erratic timer operation

Postby howard123 » Fri Jan 19, 2018 11:01 am

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.

regards
Howard

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: Erratic timer operation

Postby Kenrix2 » Sat Jan 20, 2018 3:01 am

There is nothing wrong with the chip's timers. This is a Flowcode bug.
These users thanked the author Kenrix2 for the post:
howard123 (Sat Jan 20, 2018 8:38 am)
Rating: 5.26%