Page 1 of 1

Use of T1 timer component

Posted: Mon Dec 20, 2021 10:50 am
by jadiflow
Hi,

I'd like to use the T1 counter of the PIC16F15355 for an up to 10 minutes delay.
There is a Timer1 component in Flowcode 9 I want to use, but it is basically undocumented.
Some experiments lead to the following issues:

What is the relationship between Instruction Rate, Rollover Frequency and Rollover Time?
Also, what do the entries 'Timer delay (ms)' and 'Decimal points' signify?

When I change the project clock frequency and/or the clock frequency setup in the Project Options, they all seem to do something but I can't find any logic in the relation of these settings.

When I measure a delay, the reported time always falls short of the delay I set, up to 25% short.

When I set up the T1 clock frequency directly in the T1 registers, that doesn't seem to make a difference either.
Does the Timer component override this?

Does anyone have any documentation on this Component?

Jan Didden
Linear Audio

Re: Use of T1 timer component

Posted: Mon Dec 20, 2021 11:11 am
by Benj
Hello,

A PIC device runs at 1/4 of the clock speed so at 8MHz the instruction rate is 2MHz.

The timer component sets up the timer to run at the max frequency 1:1 and so will at this rate generate an interrupt 30.5175 times a second (2MHz / 65536). Or every 0.032768 seconds. The component uses these settings to calculate the elapsed time. I'll get some more tooltips added to the properties to better explain what's happening.

Note you do not need to setup or configure the timer using any C code etc the component will do all this for you.

What sort of values are you getting on the display and is this using simulation or running on hardware?

In simulation the component relies on windows timing events and as such will always be a bit slow. You can try and improve things by increasing the timer delay to say 500ms and this way there are 10x less events we need to wait for.

On hardware the timer should be king and be very accurate depending on the accuracy of your oscillator source.
eDD V8 control 15355 timer test.fcfx
(20.99 KiB) Downloaded 144 times

Re: Use of T1 timer component

Posted: Mon Dec 20, 2021 11:28 am
by jadiflow
Thank you Ben, that's very useful, picture is clear now.
With the increased delay (500ms) the count is off by max 1 count (in simulation) which probably is a rounding in the conversion.

One more question: in simulation, what clock speed is used, the actual device clock speed or the clock speed entered in the Project Options clock speed field?
What is the significance of the Decimal Points entry in the Component?

Jan Didden
Linear Audio

Re: Use of T1 timer component

Posted: Mon Dec 20, 2021 11:37 am
by Benj
Hi Jan,

The simulation runs as fast as it can run, it doesn't try to simulate the chip's clock speed.

The decimal points property simply specifies the number of decimal points shown on the timer component when simulating. The timer component in your project was tiny so I saved a copy above where I scaled it up to a better size so you can see the counter.

Re: Use of T1 timer component

Posted: Mon Dec 20, 2021 12:30 pm
by jadiflow
Thanks! All sorted now.

Jan Didden
Linear Audio