Timer or interupt?

For general Flowcode discussion that does not belong in the other sections.
hippalator
Posts: 29
http://meble-kuchenne.info.pl
Joined: Tue Jul 15, 2025 9:05 pm
Has thanked: 4 times

Re: Timer or interupt?

Post by hippalator »

medelec35 wrote:
Sat Nov 22, 2025 5:21 pm
An easy way of setting a timer interrupt up is by using the Timed Interval component (Component Libraries > Math > Timing)
No calculations are necessary :-)
All you need to do is first add a new User Macro for the timer to call when interrupt is triggered.
Then within properties, select the time unit (Days, Hours, Minutes. Seconds, Milliseconds, or Microseconds)
Enter Time Period then finally Use the Callback Macro to select the new User Macro that was created.

Finally Drag the StartTimerInterval component function on to the start of Main (or anywhere suitable).
Timers are apparently my kriptonite.
I tried your advice using the Timed Interval component with no avail.
Timer is set to Milliseconds with 500 as the period.
In the user macro I simply added an output to an LED to toggle with a "!1".
The LED turns on and stays on.
Was hoping it would blink every second.
Any clue what I'm doing wrong?

LeighM
Valued Contributor
Posts: 521
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 89 times
Been thanked: 275 times

Re: Timer or interupt?

Post by LeighM »

"!1" ?
That won't toggle.
As usual, it's best if you can attach your program file, then we can see what exactly you are doing.

hippalator
Posts: 29
Joined: Tue Jul 15, 2025 9:05 pm
Has thanked: 4 times

Re: Timer or interupt?

Post by hippalator »

"!1" ?
That won't toggle.
As usual, it's best if you can attach your program file, then we can see what exactly you are doing.
[/quote]
Screenshot (7).png
Screenshot (7).png (243.41 KiB) Viewed 33 times
LeighM wrote:
Thu Dec 11, 2025 10:11 pm

The idea here is to set up a timer to overflow every half second to trigger a user macro that will toggle an LED.

chipfryer27
Valued Contributor
Posts: 1776
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 394 times
Been thanked: 603 times

Re: Timer or interupt?

Post by chipfryer27 »

Hi

Following on from the posts above, there are indeed countless ways to achieve what you want to do, each with their own merits.

Medelec35 suggested the Timer Interval component and I have attached an example of how it could be used to toggle an LED attached to pin C0 of a PIC16F18877.

You will see that there are two components, an LED on Port C0 and the Timer Interval component set for 500mS to call a UserMacro called Timer.

Main loop enables the Timer and then enters an endless loop which could and should be doing something useful.

Every 500mS the Timer Interval will trigger and the program will branch to the UserMacro Timer.

In here there is a calculation box that sets the value of variable "led". We then output this value to Port C0.

In simulation you will see the led flash, but depending on your simulation speed and of course speed of you PC it may be faster or slower than you expect, and don't forget your PC is doing other things too.

This is just a brief example and it could be done differently.

Regards
Attachments
Example.fcfx
(12.04 KiB) Downloaded 5 times

Post Reply