Can you mix periodic interrupts with port interrupts?
Mark Hubers
Posts: 19
Can you mix periodic interrupts with port interrupts?
·
What I mean by this is that I need to track time using interrupts and to watch for a button.· Maybe it would be easier to just state what I am trying to do...
·
1) Program starts up and gets some things setup.
2) Goes to sleep and waits for a button to get tapped.· But this tapping of the button needs to know if it has been tapped or if it has been held down for a few seconds.
3- a)·If it was just tapped then get out of sleep mode.· Start a countdown and keep monitoring the button to see if it has been tapped again, then add some time to the countdown counter.· As it is doing this, it needs to monitor some others tasks too...
·
3-b) If it has been held down for a few seconds, just get out of sleep mode and do some functions…
·
So I was thinking of the only way to pull that off if the interrupts can do both periodic interrupts with port interrupts.· The periodic would be dealing with the countdown as it is still doing other tasks outside the interrupt.· The port triggered interrupts would moniter the button and wakeup the program if in sleep.· Can this be done using interrupts and if so,· is there something to look at to get a idea how to do this?
·
Thanks for any help!
Mark
·
·
What I mean by this is that I need to track time using interrupts and to watch for a button.· Maybe it would be easier to just state what I am trying to do...
·
1) Program starts up and gets some things setup.
2) Goes to sleep and waits for a button to get tapped.· But this tapping of the button needs to know if it has been tapped or if it has been held down for a few seconds.
3- a)·If it was just tapped then get out of sleep mode.· Start a countdown and keep monitoring the button to see if it has been tapped again, then add some time to the countdown counter.· As it is doing this, it needs to monitor some others tasks too...
·
3-b) If it has been held down for a few seconds, just get out of sleep mode and do some functions…
·
So I was thinking of the only way to pull that off if the interrupts can do both periodic interrupts with port interrupts.· The periodic would be dealing with the countdown as it is still doing other tasks outside the interrupt.· The port triggered interrupts would moniter the button and wakeup the program if in sleep.· Can this be done using interrupts and if so,· is there something to look at to get a idea how to do this?
·
Thanks for any help!
Mark
·
Comments
Can you mix periodic interrupts with port interrupts?
What I mean by this is that I need to track time using interrupts and to watch for a button. Maybe it would be easier to just state what I am trying to do...
1) Program starts up and gets some things setup.
2) Goes to sleep and waits for a button to get tapped. But this tapping of the button needs to know if it has been tapped or if it has been held down for a few seconds.
3- a) If it was just tapped then get out of sleep mode. Start a countdown and keep monitoring the button to see if it has been tapped again, then add some time to the countdown counter. As it is doing this, it needs to monitor some others tasks too...
3-b) If it has been held down for a few seconds, just get out of sleep mode and do some functions…
So I was thinking of the only way to pull that off if the interrupts can do both periodic interrupts with port interrupts. The periodic would be dealing with the countdown as it is still doing other tasks outside the interrupt. The port triggered interrupts would moniter the button and wakeup the program if in sleep. Can this be done using interrupts and if so, is there something to look at to get a idea how to do this?
Thanks for any help!
Regards,
Mark
-Phil
and checking the port B pending bits from inside the isr. These bits get set even
when not generating an interrupt. Some latency will
occur. At 100_000 interrupt rate, the latency is
10 usec maximum but for a button that doesn't matter.
regard peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bad spellers of the world untie!