Interupt every 1 second

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
Walbeek
Flowcode v5 User
Posts: 68
Joined: Thu Mar 01, 2007 10:48 am
Location: Netherlands
Been thanked: 3 times
Contact:

Interupt every 1 second

Post by Walbeek »

Hi there,

Is it possible to have a interrupt every 1 second, to send information on CAN?
I have inserted an interrupt and set it to TMR0 (internal clock of 20MHz)
Prescaler is 1:256 so the frequency is 76.294 Hz.
I can use a counter from zero to 76 and than have an overflow on approx. a second.
How can I use the value of the counter to generate another Interrupt to start the "send on CAN" macro?
Or is there another way to generate the 1 second interrupt?
Please let me know.

Rinie
Greetings, Rinie
Flowcode V7 user

prasha920
Posts: 30
Joined: Tue Apr 16, 2013 3:10 pm
Has thanked: 48 times
Been thanked: 9 times
Contact:

Re: Interupt every 1 second

Post by prasha920 »

hello Rinie,

The method you used to generate the 1 sec interrupt is proper one.
How can I use the value of the counter to generate another Interrupt to start the "send on CAN" macro?
when the counter overflows set flag(say send_can_flag) and clear this flag at the end of the main loop.
and just before clearing the flag (under main loop) put a condition that if "send_can_flag = 1" is true then call "send on CAN" macro.
Also don't forget to clear the counter on every occurrence of overflow.
hope this helps.. :D

Post Reply