ADwin-Gold II
, Manual February 2013
171
RSxxx interface
Write_Fifo_Full
ADwin
Example
Rem sending data to and receiving data from the PC while using
Rem a Fifo in ADwin-Gold II
Rem Please select the appropriate include for ADbasic / TiCoBasic
#Include
ADwinGoldII.inc / GoldIITiCo.inc
#Define
outfifo
Data_1
#Define
infifo
Data_2
#Define
rs_adr
5
#Define
rs_channel
1
Dim
outfifo
[
1000
]
As
Long
As
Fifo
Dim
infifo
[
1000
]
As
Long
As
Fifo
Dim
value
,
dummy
,
check
As
Long
Rem use LED as signal: red = sending, green = receiving,
Rem orange (red+green) = s receiving
Dim
red_led
,
green_led
As
Long
Dim
green_led_time
As
Long
Dim
led_time
As
Long
Init:
Rem reset and initialize interface
RS_Reset
(
rs_adr
)
RS_Init
(
rs_adr
,
1
,
9600
,
0
,
8
,
0
,
0
)
Fifo_Clear
(
1
)
Fifo_Clear
(
2
)
green_led
=
0
red_led
=
0
Event:
Rem sending
If
(
Fifo_Full
(
1
) >
0
)
Then
'any data present?
If
(
Write_Fifo_Full
(
rs_adr
,
rs_channel
)
=
0
)
Then
Rem send Fifo empty?
value
=
outFifo
'read value from Fifo
dummy
=
Write_Fifo
(
rs_adr
,
rs_channel
,
value
)
Rem dummy is not to be checked, since Write_Fifo_Full has
Rem proved that Fifo has empty elements.
'do LED settings
If
(
red_led
=
0
)
Then
red_led
=
1
led_time
=
Read_Timer
()
EndIf
EndIf
EndIf
Rem receiving
If
(
Fifo_Empty
(
2
) >
0
)
Then
'are there empty elements?
check
=
Read_Fifo
(
rs_adr
,
rs_channel
)
If
(
check
<> -
1
)
Then
'is a value in the receiving buffer?
inFifo
=
check
'get value into inFifo
'do LED settings
If
(
green_led
=
0
)
Then
green_led
=
1
led_time
=
Read_Timer
()
EndIf
EndIf
EndIf
'output LED settings