Ping)))
robotjj123
Posts: 3
Ping))) works for a while and then hangs. I discovered that it hangs while waiting for the transition from low to high after I change the SIG pin to an input. Any ideas?
Thank You!
·
Thank You!
·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ReadCPing
·global·ReadCPing
···bcf··center_pin
; change to output
···bcf··center_tris
···bsf··center_pin
; ping high for 5us
···movlw·sonarinitdelay
···movwf·uSeconds
···call·Delay_uS
; ping low
···bcf··center_pin
; change to input
···bsf··center_tris
···bcf··center_pin
; after a short time, anywhere from 5 secs to 1 min, hangs here
Wait4CPingSet
···btfss·center_pin
···goto·Wait4CPingSet
; turn on timer
···clrf·TMR0H····; clear tmr
···clrf·TMR0L
···bsf··T0CON, TMR0ON··; turn on tmr0
Wait4CPingTimer
···btfss·center_pin
···goto·CPingFound
···movlw·sonartimeout
···cpfsgt·TMR0L····; is tmr > w (time out) skip if f > w
···goto·Wait4CPingTimer···; no
···goto·rReadCPing
CPingFound
···movff·TMR0L, pingval
···bsf··sensor, bCPing
···incf·Sonar
···incf·Sonar
rReadCPing
···movlw·sonardelay
···movwf·mSeconds
···call·Delay_mS
···return
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com