' ********************************************************************** ' * File: uk_BAS51_024.BAS * ' * Version: 1.1 * ' * Date: 13.09.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 024 of BASCOM 8051 course. ' The program manage the activation of one of the 8 red LEDs avialable on ' the TIO 16 board that is connected to I/O connectors of GMM TST3. ' The selection of the active LED is performed through a serial console ' provided of monitor and keyboard with a fixed physical protocol at 19200 ' Baud, 8 Bit x chr, 1 Stop bit, No parity. ' This console can be 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 homonym modality provided by BASCOM 8051 (see IDE Configuration). ' The program works only when the GMM 5115 is mounted on Z2 socket of GMM TST3!! ' Inside the program the terms that identify the used signals refers to electric ' diagram and technical manual of GMM TST3!! ' ' Added instructions: None. ' ' 13/09/10: uk_BAS51_024.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 !!! ' ' TIO 16 GMM TST3 pin Z2 pin Signal Used uP ' LED resource GMM TST3 GMM 5115 GMM 5115 signal ' LD1 CN4.2 33 27 P1.0 DSW1.1 T2 DL1 P1.0 ' LD2 CN4.1 32 26 P1.1 ADC1 T2EX P1.1 ' LD3 CN4.4 31 25 P1.2 ADC2 ECI P1.2 ' LD4 CN4.3 30 24 P1.3 ADC3 CEX0 P1.3 ' LD5 CN4.6 29 23 P1.4 ADC4 CEX1 P1.4 ' LD6 CN4.5 28 22 P1.5 ADC5 P1.5 ' LD7 CN4.8 27 21 P1.6 ADC6 P1.6 ' LD8 CN4.7 26 20 P1.7 ADC7 P1.7 ' ' Signal pin COMx pin CN5 pin Z1 pin Signal Used up ' PC DB9 GMM TST3 GMM TST3 GMM 5115 GMM 5115 signal ' 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 Choice As Byte ' Selected operation Dim Dirio As Byte ' Variable with digital I/O direction Dim Iod As Byte ' Variable with digital I/O status '************************ Subroutines declaration ****************************** Declare Sub Ini_pa(dirio As Byte) ' Initialize GMM TST3 port A Declare Sub Set_pa(iod As Byte) ' Set GMM TST3 port A '****************************** Main program *********************************** Main: Pinrx = 1 ' Initialize signals for serial communication Pintx = 1 ' as digital inputs Call Ini_pa(&Hff) ' Initialize lines connected to port A as outputs Print ' Separate from previous visualization by showing an empty new line Print " Turn on red LEDs of TIO 16" Print "Mount Mini Module on Z2 of GMM TST3 and connect TIO 16 to CN4." Print Iod = &HFF ' Set initial combination for all LEDs off Do ' Begin endless loop Print ' Require key for LED to turn on Print "Press key 1..8 to turn on relative LED LD1..LD8:"; Choice = Waitkey() ' Wait key pressed on console Printbin Choice ' Shows pressed key ' Obtain status of all the 8 lines of port according with pressed key, in ' reversed logic, that is bit at 0 level turn on the LED and viceversa Select Case Choice ' Check pressed key Case "1": ' Scelta operazione di generazione messaggio Iod = &HFE ' Set combination that turn on LD1 Case "2": Iod = &HFD ' Set combination that turn on LD2 Case "3": Iod = &HFB ' Set combination that turn on LD3 Case "4": Iod = &HF7 ' Set combination that turn on LD4 Case "5": Iod = &HEF ' Set combination that turn on LD5 Case "6": Iod = &HDF ' Set combination that turn on LD6 Case "7": Iod = &HBF ' Set combination that turn on LD7 Case "8": Iod = &H7F ' Set combination that turn on LD8 Case Else: ' Invalid selection Printbin &H07 ' Generate an audible advise with a BEL End Select Call Set_pa(iod) ' Drive red LEDs with obtained combination Loop ' End endless loop End '*************************** End of main program ******************************* '*********************** Subroutines used by program *************************** ' Initializes the 8 pins of uP connected to port A on CN4 of GMM TST3: ' PA.0 -> P1.0 PA.1 -> P1.1 PA.2 -> P1.2 PA.3 -> P1.3 ' PA.4 -> P1.4 PA.5 -> P1.5 PA.6 -> P1.6 PA.7 -> P1.7 ' with the I/O modality passed in dirio parameter (bit at 1=output at high ' level; bit at 0=input), by leaving unchanged the status of all the other ' lines. ' Note: On GMM 5115 the digital I/O are quasi-bidirectional and they don't have ' direction settable. Thus the subroutine doesn't set direction on these lines ' and it has been developed for compatibility and code exchange with other ' Mini Modules. Sub Ini_pa(dirio As Byte) P1 = &HFF ' Set lines direction Iod = P1 End Sub ' Set status of the 8 lines of uP connected to port A on CN4 of GMM TST3, ' with the status passed in Iod parameter, by leaving unchanged all the other ' lines. ' Note: On GMM 5115 all the lines of GMM TST3 port A are connected to port 1 of ' uP. Thus, the subroutine has only one instruction and it has been developed ' for compatibility and code exchange with other Mini Modules. Sub Set_pa(iod As Byte) P1 = Iod ' Set lines status End Sub '******************* End of subroutines used by program ************************