' ********************************************************************** ' ** Program : gmbiote.bas - Version : 1.1 - 24 June 2003 ** ' ** Compiler : BASCOM 8051 DEMO, (IDE and LIB V.2.0.11.0) ** ' ** Board : GMB HR84 with CAN GMx or GMM yyyy ** ' ** Corporate: grifo(r) ITALIAN TECHNOLOGY ** ' ** Via Dell' Artigiano 8/6 40016 San Giorgio di Piano (BO) ** ' ** Tel.+39 051 892 052 Fax +39 051 893 661 ** ' ** http://www.grifo.com http://www.grifo.it ** ' ** sales@grifo.it tech@grifo.it grifo@grifo.it ** ' ** ** ' ** Written by: Graziano Gaiba ** ' ********************************************************************** ' ' This demo allows to use immediatly TTL I/O digital lines available on CN4. ' According to Mini Module used, the list of lines existing is printed. ' After selecting the line to use it can be managed as input (its status is ' shown continuously on console) or as output (setting it high or low). ' Should the line selected be associated to Real Time Clock, this peripheral ' manages it. ' ' 24.06.03 - Rel 1.1 By Graziano Gaiba ' ' The file compiled is smaller than 2048 bytes, so it can be compiled ' with free demo version of BASCOM 8051. ' '****************** Compiler directives ************************** ' ' Set to 80h internal memory limit by: ' Options/Compiler/Misc $regfile = "grifo_mm.dat" $romstart = &H0 ' start address of code for FLASH $ramstart = &H0 ' start address of external RAM $ramsize = &H100 ' 256 bytes of external RAM $crystal = 14745600 ' Microcontroller clock $baud = 19200 ' RS-232 baud rate '$large ' 16 bit addressing for jumps ' (Not for demo version) $map ' Generates address map ' '****************** Constants declatation *********************** ' Const Cret = 13 ' Carriage return Const Nl = 10 ' New line Const Clrscr = 12 ' Clear screen Const Bell = 7 ' Bell ' Board where the demo is running Const Can_gm1 = "1" Const Can_gm2 = "2" Const Gmm_5115 = "3" ' '****************** Variables declaration ********************** ' ' Board where the demo is running Dim Scheda As Byte ' Generic use Dim R As Byte , C As Byte , V As Byte , T As Byte Dim S As Byte Dim Vbit As Bit ' Inputs Dim In As Byte ' Interrupts counters Dim Cntintr1 As Byte , Cntintr2 As Byte , Cntintt0 As Byte ' '********************* Procedures declaration ************************** ' Declare Sub Init() ' Initialization Declare Sub Setp1234input() ' Set all ports as input ' '************************** Main program ****************************** ' Main: Call Init() ' Inizializes demo Print Chr(clrscr); ' Clear screen Print "Demo 1.1 for GMB HR84 ds 100203" Print Print "Which Mini Modulo grifo(r) is the demo running on:" Print "1) CAN GM1" Print "2) CAN GM2" Print "3) GMM 5115" Print Print "SELECT: "; Do Scheda = Inkey() ' Stand by a key Loop Until Scheda <> 0 Do Print Chr(clrscr) Print "These pins are I/O TTL on CN4:" Print Print "1) Pin 8 (4,7 Kohm pull down always present)" Print "2) Pin 6" If Scheda = Can_gm1 Then Print "3) Pin 4" Print "4) Pin 2" End If If Scheda = Can_gm2 Then Print "3) Pin 4" End If If Scheda = Gmm_5115 Then Print "3) Pin 3" Print "4) Pin 5" End If Print Print "SELECT: "; Do V = Inkey Loop Until V <> 0 Print Chr(v) If V = "3" And Scheda <> Gmm_5115 Then Print "Pin 4 is connected to RTC interrupt; it can:" Print "generate square waves; activate every enth,second,minute,hour,day" Print "or at a preset time." Print "LED LD6 of GMB HR84 shows its status." Print "Hit a key to exit." Do S = Inkey Loop Until S <> 0 Else Print Print "Input/Output (I/O)? "; Do R = Inkey() ' Stand by a key Loop Until R <> 0 Print Chr(r) R = R Or &H20 ' Convert in lower case If R = "i" Then Call Setp1234input() ' Set all port in input Print "Premere tasto per uscire" Print "Stato pin:" Do If V = "1" Then Vbit = P1.0 ' Pin 8 of CN4 End If If V = "2" Then Vbit = P1.3 ' Pin 6 of CN4 End If If V = "3" Then Vbit = P4.0 ' Pin 3 of CN4 End If If V = "4" Then If Scheda = Can_gm1 Then Vbit = P2.2 ' Pin 2 of CN4 End If If Scheda = Gmm_5115 Then Vbit = P4.1 ' Pin 5 of CN4 End If End If Print Vbit ; Chr(13); Waitms 200 S = Inkey Loop Until S <> 0 Else Do Print "Status pin (0/1,2 exit): "; Do C = Inkey Loop Until C <> 0 Print Chr(c) C = C - 48 ' Convert from numeric char to value If C = 0 Or C = 1 Then Vbit = C.0 If V = "1" Then P1.0 = Vbit ' Pin 8 of CN4 End If If V = "2" Then P1.3 = Vbit ' Pin 6 of CN4 End If If V = "3" Then P4.0 = Vbit ' Pin 3 of CN4 End If If V = "4" Then If Scheda = Can_gm1 Then P2.2 = Vbit ' Pin 2 of CN4 End If If Scheda = Gmm_5115 Then P4.1 = Vbit ' Pin 5 of CN4 End If End If End If Loop Until C = 2 End If End If Loop End ' '************************ Program end *************************** ' ' '**************************** Procedures ******************************** ' ' Initializes demo Sub Init() Disable Interrupts ' Disabiles interrupts Ckcon = &H00 ' Set X1 clock mode = standard mode Auxr = &H0C ' Selects Eram on external data area Eecon = &H00 ' Disables Eeprom of Micro End Sub ' Set as input all port Sub Setp1234input() Adcf = &H00 ' Set P1 as I/O P1 = &HFF ' Set P1 as input C = P1 P2 = &HFF ' Set P2 as input C = P2 P3 = &HFF ' Set P3 as input C = P3 P4 = &HFF ' Set P4 as input C = P4 End Sub