Previous in Forum: Fires from Lights   Next in Forum: Soft Starter / Energy Saving
Close
Close
Close
2 comments
Rate Comments: Nested
Associate

Join Date: Jul 2007
Posts: 26

pic help

10/02/2007 12:15 PM

hi

i am programming a pic 16f877

i am already implementing interrupt to allow counting whenever a switch is closed on RB0;i also want to be able to read a card reader or keypad when a card is inserted or a key is pressed,i dont want to us polling but this pic does not support interrupt priorities so i cannot assign the most important interrupt which is the counting a higher priority

this is what i dont want--i dont want the card reader to be reading from a card then ignore the counter when a switch is closed,i want it to detect the closed switch even when a card is detected and is being read

any ideas please?

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru
Engineering Fields - Electrical Engineering - New Member

Join Date: Sep 2006
Location: El Lago, Texas, USA
Posts: 2639
Good Answers: 65
#1

Re: pic help

10/02/2007 2:37 PM

Read the input from the switch as a 1 or 0, and just keep adding it to the counter. Set it so that when the switch is closed, the input is 1 - and you count. When the switch is open, the input is 0 - you're still adding, but you're no longer incrementing. Then you can use the interrupt for your card reader.

Register to Reply
Guru

Join Date: Dec 2005
Location: Etats Unis
Posts: 1871
Good Answers: 45
#2

Re: pic help

10/03/2007 1:01 AM

As long as the interrupts come in on different peripherals, or you can use the interrupt on change feature which latches the changed port bits, you will have a record of all the interrupts that were active. If you want to make one of the events low priority, just set a flag that it occurred in the interrupt routine and deal with responding to it in your main loop. You can still attend to your high priority routine in the interrupt code but just put off servicing the low priority event until you have exited the interrupt. Then if required your faster or more frequent high priority event is always serviced even when you are completing the service of a lower priority event outside the interrupt routine.

__________________
The hardest thing to overcome, is not knowing that you don't know.
Register to Reply
Register to Reply 2 comments

Previous in Forum: Fires from Lights   Next in Forum: Soft Starter / Energy Saving

Advertisement