Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/13/10 18:35
Modified:
  02/13/10 18:43

Read: times


 
#173130 - Look At This
Responding to: ???'s previous message
Eatzik:

You may want to look at the code posted in conjunction with a state machine tutorial that I posted a few years ago. This example code shows the use of a timer interrupt to poll port pins and look for changes.

State Machine Tutorial
http://www.8052.com/forum/read/136365 <-- Original Posting
http://www.8052.com/forum/read/47505 <-- Later Updated Posting

Sometimes the best way to get your feet wet is to step right in, read the docs that Erik and Andy have pointed you to and then study the tutorial code.

The tutorial code is really a bit more complex then what you need for your application but you should be able to pare it down to specifically apply to your problem. The code in the tutorial is designed to poll each port pin on Port 2 individually and if a change is detected to then produce a pulse out the corresponding Port 3 pin. For your problem you will want, at each poll, save the current port input content to a variable in the RAM. Then at the next poll time you XOR the saved value against the new present value. If the result of the XOR is non-zero then you know there has been a change and you can take action accordingly.

Michael Karas





List of 6 messages in thread
TopicAuthorDate
help with timer interrupt for pins state            01/01/70 00:00      
   clarify?            01/01/70 00:00      
      replay            01/01/70 00:00      
         bible time            01/01/70 00:00      
         Time to read the Tutorials, then            01/01/70 00:00      
   Look At This            01/01/70 00:00      

Back to Subject List