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
Interupt every 1 second
-
- Posts: 30
- Joined: Tue Apr 16, 2013 3:10 pm
- Has thanked: 48 times
- Been thanked: 9 times
- Contact:
Re: Interupt every 1 second
hello Rinie,
The method you used to generate the 1 sec interrupt is proper one.
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..
The method you used to generate the 1 sec interrupt is proper one.
when the counter overflows set flag(say send_can_flag) and clear this flag at the end of the main loop.How can I use the value of the counter to generate another Interrupt to start the "send on CAN" macro?
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..