Help with timer

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
RLOPES780
Posts: 119
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 3 times
Contact:

Help with timer

Post by RLOPES780 »

I'm working with the dspic33ep512mu 810 and a 48 mhz crystal.
I need a timer with a frequency of 1 hz.
Due to the timer properties in the flowcode, the frequency of at least 1,431 hz ((Fosc / 2) (1: 256) (65536)) can be done. What trick can I do to achieve the timer frequency of 1 hz, without changing the crystal (48 mhz).

Thankful;

Ricardo.
Attachments
simplecode.fcfx
(7.89 KiB) Downloaded 220 times

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Help with timer

Post by kersing »

You could try to calculate a more frequency interrupt (like 5 a second) and use a counter in the interrupt handler to only execute the code you need to run at 1 hz when the counter reaches 5.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

RLOPES780
Posts: 119
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 3 times
Contact:

Re: Help with timer

Post by RLOPES780 »

Hello kersing;
grateful for the attention.

Can you give me an example in flowcode?

Hugs;

Ricardo.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Help with timer

Post by kersing »

I don’t have a computer with Flowcode handy for the next 48 hours so may-be you can try yourself and post the result here for me to take a look at after the weekend?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

RLOPES780
Posts: 119
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 3 times
Contact:

Re: Help with timer

Post by RLOPES780 »

Hello Kersing;

Sorry, we're over the weekend. Make the most of it.
I didn't even realize it, it was my excitement.
I made a little code. Would it be more or less like this?
See you on Monday.

Thankful;

Ricardo.

RLOPES780
Posts: 119
Joined: Tue Apr 07, 2015 11:01 am
Been thanked: 3 times
Contact:

Re: Help with timer

Post by RLOPES780 »

simgle file
Attachments
simplecode.fcfx
(8.89 KiB) Downloaded 220 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: Help with timer

Post by Benj »

Hello,

Here's an example of what Kersing suggested.

I ramped the timer rate up to 25Hz and then using a variable I count the number of interrupts up to 25 to give the 1Hz interrupt you require.
simplecode.fcfx
(9.59 KiB) Downloaded 262 times

Post Reply