There is no easy or automatic way to do it, as far as I know, except that you can realize a 1-0-1 or 0-1-0 transition with PULSIN. If you only want to detect 0-1 or 1-0 then you must do it manually. Here is the basic untested process, although there may be simpler ways of doing it:
/code
pulsed_pin pin p0 ' arbitrarily check pin port 0
First_Status: 'Very first excursion ONLY otherwise use Check_Pin: entry
curr_status = pulsed_pin 'Save current pin state
last_status = curr_status 'Dummy last pin state
Check_Pin: 'Normal entry point
curr_status = pulsed_pin 'Fetch current pin state · IF curr_status <> last_status GOTO pin_change 'Has there been an edge transition?
GOTO Check_Pin 'No edge transition occured
Pin_Change: 'Edge transition occured, check which way · IF curr_status < last_status GOTO Low_Trans: 'Did it go high to low
High_Trans: 'Transition was low to high
trans_state = 1 ' set direction of transition
GOTO Trans_Occurred 'Prepare to exit
Low_Trans:
trans_state = 0 ' set direction of transition
Trans_Occured: 'Prepare to exit
last_status = curr_status
code/
That should get you started.
Regards,
Bruce Bates
Post Edited (Bruce Bates) : 12/30/2005 6:52:16 AM GMT
Comments
There is no easy or automatic way to do it, as far as I know, except that you can realize a 1-0-1 or 0-1-0 transition with PULSIN. If you only want to detect 0-1 or 1-0 then you must do it manually. Here is the basic untested process, although there may be simpler ways of doing it:
/code
pulsed_pin pin p0 ' arbitrarily check pin port 0
First_Status: 'Very first excursion ONLY otherwise use Check_Pin: entry
curr_status = pulsed_pin 'Save current pin state
last_status = curr_status 'Dummy last pin state
Check_Pin: 'Normal entry point
curr_status = pulsed_pin 'Fetch current pin state
· IF curr_status <> last_status GOTO pin_change 'Has there been an edge transition?
GOTO Check_Pin 'No edge transition occured
Pin_Change: 'Edge transition occured, check which way
· IF curr_status < last_status GOTO Low_Trans: 'Did it go high to low
High_Trans: 'Transition was low to high
trans_state = 1 ' set direction of transition
GOTO Trans_Occurred 'Prepare to exit
Low_Trans:
trans_state = 0 ' set direction of transition
Trans_Occured: 'Prepare to exit
last_status = curr_status
code/
That should get you started.
Regards,
Bruce Bates
Post Edited (Bruce Bates) : 12/30/2005 6:52:16 AM GMT
I was hoping there might be a simple way by using probably polling or interrupts to detect edges, but i think this shd be able to do the job. thks!!