' ********************************************************************** ' * File: uk_BAS51_009.BAS * ' * Version: 1.1 * ' * Date: 10.05.10 * ' * Development Tools: Bascom 8051 COMP.,IDE 2.0.14.0 + FLIP 2.4.6 * ' * Cards: GMM 5115 + GMM TST3 * ' * Developed by: GRIFO(r) Italian Technology * ' * via Dell'Artigiano 8/6 * ' * 40016 S. Giorgio di Piano (BO) * ' * Tel. +39 051 892052 Fax. +39 051 893661 * ' * http://www.grifo.com http://www.grifo.it * ' * Author: Gianluca Angelini * ' ********************************************************************** ' Example program 009 of BASCOM 8051 course. ' It manages the RS 232 serial communication line of GMM 5115. ' The program receives 20 characters from serial line and when arrived it ' transmit them on the same line. The communication uses a fixed physical ' protocol at 19200 Baud, 8 Bit x chr, 1 Stop bit, No parity. ' The program must interact with another system capable to support a serial ' RS 232 communication. In order to simplify the use it can be used a PC ' provided of one COMx line, that execute a terminal emulation program as ' HYPERTERMINAL or the homonimous modality provided by BASCOM 8051 (see IDE ' Configuration). ' When GMM 5115 executes the program it is sufficient to press 20 keys on PC ' keyboard (the terminal emulation transmits the keys to Mini Module) and these ' will be immediately displayed on PC monitor (the terminal emulation program ' shows the received characters, from Mini Module, on monitor). ' ' Added instructions: $baud, Dim for array declaration, For, Next, Waitkey, Print. ' ' 10/05/10: uk_BAS51_009.BAS - Ver 1.1 - By G.A. ' First version. ' ' '**************************** IDE Configurations ******************************* ' NOTE: in order to coorectly use this demo program, please execute the following ' steps: ' 1) Check the availability of 89C5115.DAT file into the directory where the ' BASCOM 8051 is installed and copy it if not present. ' 2) Into the window "Options | Compiler | Misc" set: ' Register File = 89C5115.DAT ' Byte End(Hex) = A0 ' Size warning = selected at 16384 (=4000H) ' 3) Into the window "Options | Communication" set: ' COM port = the PC line connected to GMM 5115, through GMM TST3 ' Baudrate = 19200 ' Parity = None ' Databits = 8 ' Stopbit = 1 ' Handshake = None ' Emulation = TTY ' Font = Terminal, Normal, 12 points, white colour ' Backcolor = Navy ' Run emulator modal = not selected ' 4) At the end of compilation, after the code is programmed on GMM 5115, select ' RUN mode and open the terminal emulation window of BASCOM 8051 with the ' option: Tools | Terminal emulator (Ctrl+T) and then reset or powen on the ' Mini Module. '************************* Compiler directives ********************************* $regfile "89C5115.DAT" ' Definitions file for used microcontroller $romstart = &H0 ' Code start address on FLASH $iramstart = &H0 ' Data start address on internal RAM $ramstart = &H0 ' Data start address on external RAM $ramsize = &H100 ' External RAM size $crystal = 14745600 ' Microcontroller crystal frequency $large ' Code size > 2K $map ' Generate debug information $baud = 19200 ' Serial communication speed: 19200 Baud ' Other parameters fixed to: 8 bit x chr ' 1 Stop bit ' No parity '******************************* Definitions *********************************** ' The resources used by program are connected as described in following table: ' !!! Note: On GMM TST3 the following jumpers must be properly configured: ' J1 in 2-3 ; J3 in 1-2 ' ' Signal pin COMx pin CN5 pin Z1 pin Signal Signal ' PC DB9 GMM TST3 GMM TST3 GMM 5115 GMM 5115 uP ' TX 3 3 9 3 RxD RS232 P3.0 ' RX 2 2 10 4 TxD RS232 P3.1 ' GND 5 5 20 14 GND - ' This table shows that the connection cable between PC COM line and CN5 of ' GMM TST3 is a normal pin to pin cable or direct. Grifo(r) can supply it by ' requesting the CCR 9+9E code. Pinrx Alias P3.0 ' Signal connected to GMM 5115 RxD Pintx Alias P3.1 ' Signal connected to GMM 5115 TxD '************************* Constants declaration ******************************* '************************* Variables declaration ******************************* Dim Nchr As Byte ' Characters counter Dim Datrx(20) As Byte ' Array with 20 characters received '************************ Subroutines declaration ****************************** '****************************** Main program *********************************** Main: Pinrx = 1 ' Initialize signals for serial communication Pintx = 1 ' as digital inputs Do ' Begin endless loop For Nchr = 1 To 20 ' Begin 20 characters reception loop Datrx(nchr) = Waitkey() ' Wait character reception and save it on array Next Nchr ' End 20 characters reception loop For Nchr = 1 To 20 ' Begin 20 characters transmit loop Print Chr(datrx(nchr)); ' Transmit character saved on array Next Nchr ' End 20 characters transmit loop Print ' Separate following transmission, by showing a new line Loop ' End endless loop End '*************************** End of main program *******************************