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.
Help with timer
Moderator: Benj
-
- 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
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
― C.S. Lewis
Re: Help with timer
Hello kersing;
grateful for the attention.
Can you give me an example in flowcode?
Hugs;
Ricardo.
grateful for the attention.
Can you give me an example in flowcode?
Hugs;
Ricardo.
-
- 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
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
― C.S. Lewis
Re: Help with timer
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.
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.
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel