??? 05/02/10 06:32 Read: times |
#175600 - Here is the method I have been using... Responding to: ???'s previous message |
Here is the method I have been using over the years, especially for Barcode readers.
Give the pulse input to one input of an XOR+NOT gate. The other input from IO pin of micro. Enable the interrupt for Edge trigger. In the ISR first thing is toggle the IO Pin. If you look at the truth table of XOR. the output of XOR will always be low. Because of the inverter, the INTx pin will be high. If Pulse=1, and Px.y=1 then XOR=0, INTx=1 If Pulse=0, and Px.y=1 then XOR=1, INTx=0,(Interrupt) in ISR Make Px.y=0 If Pulse=0, and Px.y=0 then XOR=0, INTx=1 If Pulse=1, and Px.y=0 then XOR=1, INTx=0,(Interrupt) in ISR Make Px.y=1 If Pulse=1, and Px.y=1 then XOR=0, INTx=1 So now you have interrupt on both the edges of the pulse input. In case of barcode, use a timer value and record them and intialize them for next ISR. But I believe Joseph Hebert's method is much better than the I have been using. |