'---------------------------------------------------------------------------------------- ' Name: SER1_DEMO_XON_XOFF.TIG ' Type: TIGER-BASIC(tm) Source Code ' Purpose: Short demo for XON/XOFF handshake with "SER1B_xxx.TDD" driver (from V1.02b) ' ' (C) - Copyright Wilke Technology, P.O.Box 1727, D-52018 Aachen, Germany '---------------------------------------------------------------------------------------- ' ' Thank you for using BASIC Tigers in your products. If you have questions, ideas ' or special needs, please contact your next distributor or the Tiger support team ' and visit our web site: ' ' Wilke Technology GmbH ' The Tiger Support Team ' P.O.Box 1727, D-52018 Aachen, Germany ' Krefelder Str. 147, D-52070 Aachen, Germany ' ' email: support@wilke-technology.com (english) ' email: support@wilke.de (german) ' Phone: +49 (241) 918 900 Mo to Fr, 7:00 to 16:00 (GMT) ' Fax: +49 (241) 918 9068 ' ' New information, new drivers and free downloads see: ' ' www.wilke-technology.com (english) ' www.wilke.de (german) ' ' Sincerely, ' ' Your Tiger Support Team ' '---------------------------------------------------------------------------------------- ' ' Demo compiled with a ACN-4/4 Tiger module on the "Plug & Play Lab" ' ' After download into the Tiger do following: ' ' * Disconnect RS-232 cable to PC ' * Make jumper connections: CTS0 (L92) to GND ' TxD0 to scope or terminal etc. to watch driver handshake ' TxD1 to RxD0 ' * Set "RUN-Mode" + reset the Tiger. ' ' ' The serial channel-0 is set to XON/XOFF protocol and serial channel-1 ' transmits bytes into Ch-0 until Ch-0 buffer gets filled. ' ' At a level of 80 FREE bytes in RxD-0 buffer a char is issued through ' TxD-0 to signal that the level of free space is going below that (default) level. ' ' After continuously more bytes are coming in through RxD-0 channel the buffer-free ' level is falling below 20 bytes of free space in this buffer. This causes the ' driver to fall into the "forced-close" state sending a character now with every ' byte coming in through RxD-0. ' ' Though, as long as space is available in receive buffer, bytes will be received correctly. ' Data loss starts to occur of course, when buffer is full (FREE=0). ' ' ' At the end of Task "MAIN" a GET instruction is emptying the receive buffer partially, ' causing the Ch-0 to issue a char. ' '---------------------------------------------------------------------------------------- USER_VAR_STRICT ' check for var declaration STRING X$ (1K) ' #INCLUDE DEFINE_A.INC ' general symbol definitions '---------------------------------------------------------------------------------------- ' Task MAIN: Load drivers, initialize vars, start tasks '---------------------------------------------------------------------------------------- TASK MAIN ' begin task MAIN #INCLUDE DEFINE_I.INC ' general symbol definitions INSTALL_DEVICE #LCD, "LCD1.TDD" ' install LCD driver INSTALL_DEVICE #SER, "SER1B_K1.TDD",& ' install SERIAL + set the baudrates: BD_19_200, DP_8N, JA, BD_19_200, DP_8N, JA '<-----Ser-Ch-0-----> <-----Ser-Ch-1-----> ' for each channel: Baudrate, Data-/Parity, Receive-on-Error Flag PRINT #LCD, "<1>XON/XOFF Demo" ' '---------------------------------------------------------------------------------------- ' ' UFCO_DEV_OPT8 = 88H -> XON/XOFF handshake setting: FF = no = inactive, 00 = XON-XOFF ' Turns software handshake XON/XOFF on channel 0 or 1 on or OFF. ' ' UFCO_DEV_OPT9 = 89H -> XON/XOFF handshake: send or char ' ' UFCO_DEV_OPTA = 8AH -> XON/XOFF handshake: set thresholds for XON/XOFF: ' ' = Receive-CLOSE threshold: exactly at this amount of "free-buffer-space" ' the receive buffer should be closed ==> send 1 x ! ' ' = Buffer-Hysteresis: Area for the re-OPEN and "forced" close modes: ' ' 1. Buffer OPEN ' FREE sinks: Exactly at FREE = "THRESHOLD" ' ==> sends 1 x XOFF, Buffer = CLOSE ' ' If less than "THRESHOLD" - "HYST" ' ==> answer with 1 x XOFF on every char ' ' When buffer full -> characters are lost ' and every char is answered with XOFF ' ' 2. Buffer CLOSE ' FREE raises: When exceeding "THRESHOLD" + "HYST" (Free) ' ==> sends 1 x XON, Buffer = OPEN ' '---------------------------------------------------------------------------------------- PUT #SER, #0, #88H, 0 ' turn on XON/XOFF protocol on Ser-0 channel PUT #SER, #0, #89H, "<11H>" ' send character (just a test) ' PUT #SER, #0, #8AH, "80 00 20 00"% ' set: buffer close-level "80 00"% --> 128 ' hysteresis "20 00"% --> 32 PRINT #LCD, "<7>"; ' give a short sound to signal WAIT_DURATION 2000 ' wait 2 seconds RUN_TASK SER1_OUT ' <-- output on serial 1 RUN_TASK SER0_IN2 ' <-- write input on serial 0 to LCD WAIT_DURATION 50000 PRINT #LCD, "<1>230 Chars removed<7>";' GET #SER, #0, 230, X$ ' get 200 characters ! --> generate XON on TxD-0 END ' end of task MAIN '---------------------------------------------------------------------------------------- ' Task: Writes to serial port 1 '---------------------------------------------------------------------------------------- TASK SER1_OUT ' begin task SER1_OUT PRINT #SER,#1,FILL$("U", 1024-150); ' send 874 bytes ! LOOP 999999999 ' PRINT #SER,#1,"U"; ' serial channel-1 WAIT_DURATION 250 ' send chars one-by-one - until full (and more) ENDLOOP ' END ' end of task SER1_OUT '---------------------------------------------------------------------------------------- ' Task: Show fill level of serial 0 input '---------------------------------------------------------------------------------------- TASK SER0_IN2 ' begin task SER0_IN2 LONG FREE LOOP 999999999 ' ' #2 = UFCI_IBU_FREE GET #SER, #0, #2, 0, FREE ' read "free" space of buffer PRINT #LCD,"<27>A<6><1><240>";FREE;" <<- Free "' WAIT_DURATION 50 ' wait 50 ms ENDLOOP ' END ' end of task SER0_IN2