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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/11/04 10:52
Read: times


 
#70165 - RE: branching ports through memory mapping
Responding to: ???'s previous message
hi,
IMHO, for such puproses I preffer to use timer-based solution. It has nothing with State Machine; nevertheless, it does this task more easy and clean.

What I whould use is a timer which ISR checks for input events. It requires next:
- a timer;
- two bytes for variables (one per each input event);
- two bits as flags (one per each input event as well).

Now how does it may work:

1) initialization state.
- clear both bits;
- configure timer for periodic interrupts, let say, at each 1 second;
- put initial numbers of "skips" into both variables. As interrupt comes each second so put 1 - that means we need to test pins` states each second.
- run timer.
2) timer ISR. It checks "skip" value of each input event (simple DJNZ is used here). If it does not come to zero then nothing is processed. If during DJNZ it is not bypassed then here is the time to check pin`s state. Routine checks pin`s state. If no input event occures then it reloads "skip" value (here: again the 1) and goes out. If it detects input event then we set corresponded bit (flag "process this event") and then put different "skip" value (here: 5 - that means we need to check pin`s state again after 5 second delay).
3) main loop. It just checks two flags described above. If one of them is set then main routine clears it and processes needed transaction then.

BTW, you have mentioned that debouncing is not need; anyway if it is required so such scheme shown above, helps to make it with software way inside timer`s ISR easy.


Regards,
Oleg

List of 7 messages in thread
TopicAuthorDate
branching ports through memory mapping            01/01/70 00:00      
   RE: branching ports through memory mapping            01/01/70 00:00      
      RE: branching ports through memory mapping            01/01/70 00:00      
         RE: branching ports through memory mapping            01/01/70 00:00      
            Simplifying            01/01/70 00:00      
   RE: branching ports through memory mapping            01/01/70 00:00      
      Plz close this thread            01/01/70 00:00      

Back to Subject List