TICkit
62 Sample
; Program for RSB509B serial buffering
DEF tic62_c
LIB fbasic.lib
LIB rsb509b.lib
FUNC none main
BEGIN
; generate a long pulse on interface pin to
; signal initialization to RSB509
pin_high( pin_d0 )
delay( 2 )
=( in_err, pin_in( pin_d0 ))
; no match byte used but one must be sent
; as a place holder during initialization
rs_param_set( rs_invert | rs_9600 | pin_d0 )
rs_send( ' ' )
; serial input is inverted and 9600 baud.
rs_send( rsb509_invert | rsb509_baud1 )
; wait for RSB509 to reset.
delay( 1 )
REPEAT
; generate a quick pulse for each
; byte to be read. pin high creates start
; of pulse.
; rs_receive creates end of pulse
; when it makes the pin an input.
pin_high( pin_d1 )
; pin D1 will be used for input
rs_param_set( rs_invert |~
~ rs_9600 | pin_d0 )
; read each byte with a short wait
=( in_val, rs_receive( 100, 0b, in_err ))
IF in_err
ELSE
rs_param_set( debug_pin )
con_out_char( in_val )
ENDIF
LOOP
ENDFUN
|
Basic Stamp II Sample
' sample program for RSB509B on STAMP II
inval VAR byte
' generate a 10 ms pulse to signal
' initialization
HIGH 1
PAUSE 2
INPUT 1
' pin P1 is used for input.
' we are using open, inverted, 9600,
' 8N1 format. No match byte is used
' but we must send a byte to hold our place
' during initialization
SEROUT 1, 49236, [" "]
' pin P1 is used for input.
' we are using open, inverted, 9600,
' 8N1 format
' serial input is inverted and 9600 baud
SEROUT 1, 49236, [%00000100]
' wait for RSB509 to reset
PAUSE 1
around:
' generate a quick pulse for each byte
' to be read. HIGH creates the start of
' the pulse. SERIN creates the end of the
' pulse when it makes the pin an input
' because the interface pin is pulled low
HIGH 1
' pin P1 is used for input.
' we are using open, inverted, 9600,
' 8N1 format. If a byte is not received within
' 1 ms branch to "around" to poll again.
' data will only be displayed when
' byte is received
SERIN 1, 16468, 1, around, [inval]
' show character received on debug window
DEBUG inval
GOTO around
END |