Use of T1 timer component

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Use of T1 timer component

Post 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
Attachments
eDD V8 control 15355 timer test.fcfx
(20.99 KiB) Downloaded 131 times
t1comp.PNG
t1comp.PNG (27.09 KiB) Viewed 5117 times

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

Re: Use of T1 timer component

Post 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 134 times

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Use of T1 timer component

Post 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

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

Re: Use of T1 timer component

Post 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.

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Use of T1 timer component

Post by jadiflow »

Thanks! All sorted now.

Jan Didden
Linear Audio

Post Reply