'---------------------------------------------------------------------------------------- ' Name: SER2_2PORTS.TIG ' Type: TIGER-BASIC(tm) Source Code ' Purpose: Creating 2 additional serial ports with 1,200 baud on standard ' Tiger I/O pins, using the SER2 device driver ' ' (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 ' '---------------------------------------------------------------------------------------- ' ' This program demonstrates the use of additional serial I/O through device driver ' SER2_xx.TDD. Two additional serial channels are established on ' ' L80 = TxD and L81 = RxD (Port 1) ' L84 = TxD and L85 = RxD (Port 2), both running at 1200 baud. ' ' Use the Plug & Play Lab, connect L80 to L81 and L84 to L85 and the program will ' transmit data serially on L80 resp. L84, receive it on L81 resp. L85 and display ' the number of transmitted/received chars on the 4 x 20 text LCD. ' '---------------------------------------------------------------------------------------- USER_VAR_STRICT ' variables must be declared #INCLUDE DEFINE_A.INC ' general definitions #INCLUDE UFUNC3.INC ' User-Function-Codes #DEFINE SER2_1 20 ' device number for additional serial port 1 #DEFINE SER2_2 21 ' device number for additional serial port 2 LONG Rx1Cnt, Tx1Cnt, Rx2Cnt, Tx2Cnt ' global variables for counters TASK MAIN ' begin task MAIN BYTE EVER ' for endless loop STRING A$, B$ ' for received data INSTALL DEVICE #LCD, "LCD1.TDD" ' install LCD driver INSTALL_DEVICE #TA, "TIMERA.TDD",2,173 ' 1200 Bd * 3(oversample) = 3600, here: 3612 Hz ' data,par,inv,TxPre,RxOvs,-,handsh INSTALL_DEVICE #SER2_1, "SER2_80.TDD", 8, 0, 0, 3, 3,1, 0 ' L80=TxD, L81=RxD INSTALL_DEVICE #SER2_2, "SER2_84.TDD", 8, 0, 0, 3, 3,1, 0 ' L84=TxD, L85=RxD Rx1Cnt = 0 ' reset counters Tx1Cnt = 0 Rx2Cnt = 0 Tx2Cnt = 0 RUN_TASK SEND_DATA ' start task for sending data FOR EVER = 0 TO 0 STEP 0 ' endless loop GET #SER2_1, 0, A$ ' read received characters from port 1 Rx1Cnt = Rx1Cnt + LEN(A$) ' increase counter by no. of received bytes GET #SER2_2, 0, B$ ' read received characters from port 2 Rx2Cnt = Rx2Cnt + LEN(B$) ' increase counter by no. of received bytes PRINT #LCD, "<27>A<0><0><240> sended #1:"; Tx1Cnt PRINT #LCD, "<27>A<0><1><240>received #1:"; Rx1Cnt PRINT #LCD, "<27>A<0><2><240> sended #2:"; Tx2Cnt PRINT #LCD, "<27>A<0><3><240>received #2:"; Rx2Cnt WAIT_DURATION 100 ' wait 100 ms NEXT ' end of endless loop END ' end of task MAIN '---------------------------------------------------------------------------------------- ' This task continously sends a string through the additional serial I/O port. '---------------------------------------------------------------------------------------- TASK SEND_DATA ' begin task SEND_DATA BYTE EVER ' for endless loop STRING P1$, P2$ ' for sending data P1$ = "sending on port 1" P2$ = "also sending on port 2" FOR EVER = 0 TO 0 STEP 0 ' endless loop PRINT #SER2_1, P1$; ' output with PRINT to port 1 PRINT #SER2_2, P2$; ' output with PRINT to port 2 Tx1Cnt = Tx1Cnt + LEN(P1$) ' increase counter by no. of sent bytes Tx2Cnt = Tx2Cnt + LEN(P2$) ' increase counter by no. of sent bytes WAIT_DURATION 500 ' wait 500 ms NEXT ' end of endless loop END ' end of task SEND_DATA