' ********************************************************************** ' * File gmbiot.bas - Rel. 1.1 Bascom 8051 DEMO IDE e LIB 2.0.11.0 * ' * GRIFO(R) 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 * ' * sales@grifo.it tech@grifo.it grifo@grifo.it * ' * by Graziano Gaiba del 09.04.03 * ' ********************************************************************** ' ' Questo Demo permette di utilizzare immediatamente le linee di I/O digitale TTL ' presenti su CN4. A seconda del Mini Modulo utilizzato, viene presentata ' la lista delle linee disponibili. Una volta selezionata quella d'interesse ' la si puo' gestire in input (rappresentando il suo stato sulla console) o ' in output (settandola alta o bassa). Qualora la linea scelta sia associata ' all'interrupt del Real Time Clock del Mini Modulo, la gestione avviene tramite ' questa periferica. ' ' 09.04.03 - Rel 1.1 By Graziano Gaiba ' ' Il file compilato non supera i 2048 bytes, quindi puo' essere ' compilato con il demo gratuito di BASCOM 8051. ' '****************** Direttive del compilatore ************************** ' ' Impostare ad 80h il limite per la memoria interna mediante il menu: ' Options/Compiler/Misc $regfile = "grifo_mm.dat" $romstart = &H0 ' indirizzo di partenza del codice ' macchina per FLASH $ramstart = &H0 ' indirizzo di partenza della area ' dati $ramsize = &H100 ' pongo a 256 bytes la area dati $crystal = 14745600 ' frequenza di clock del microcontrollore $baud = 19200 ' velocità di comunicazione RS-232 '$large ' indirizzamento a 16 bit ' solo se si non usa la versione demo $map ' Genera una mappa degli indirizzi ' per ogni linea di codice ' '****************** Dichiarazione delle costanti *********************** ' Const Cret = 13 ' Codice di ritorno di carrello Const Nl = 10 ' Codice nuova linea Const Clrscr = 12 ' codice di clear screen Const Bell = 7 ' codice di Bell ' Codice della scheda sulla quale gira il demo Const Can_gm1 = "1" Const Can_gm2 = "2" Const Gmm_5115 = "3" ' '****************** Dichiarazione delle variabili ********************** ' ' Scheda sulla quale gira il demo Dim Scheda As Byte ' Uso generico Dim R As Byte , C As Byte , V As Byte , T As Byte Dim S As Byte Dim Vbit As Bit ' Ingressi Dim In As Byte ' Contatore interrupts Dim Cntintr1 As Byte , Cntintr2 As Byte , Cntintt0 As Byte ' '****************** Dichiarazione delle procedure ********************** ' Declare Sub Init() ' Inizializzazione Declare Sub Setp1234input() ' Setta in input tutti i port ' '************************* Programma main ****************************** ' Main: Call Init() ' Inzializza il modulo Print Chr(clrscr); ' Pulisce lo schermo Print "Demo 1.1 per GMB HR84 ds 100203" Print Print "Su quale Mini Modulo grifo(r) gira il demo:" Print "1) CAN GM1" Print "2) CAN GM2" Print "3) GMM 5115" Print Print "SELEZIONE: "; Do Scheda = Inkey() ' Attesa sospensiva di un tasto Loop Until Scheda <> 0 Do Print Chr(clrscr) Print "Su CN4 questi pin sono I/O TTL:" Print Print "1) Pin 8 (pull down da 4,7 Kohm sempre presente)" 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 "SCELTA: "; Do V = Inkey Loop Until V <> 0 Print Chr(v) If V = "3" And Scheda <> Gmm_5115 Then Print "Pin 4 e` collegato all'interrupt RTC che puo`:" Print "generare onde quadre;attivarsi ogni decimo,secondo,minuto,ora,giorno" Print "o ad un tempo preimpostato." Print "Il LED LD6 della GMB HR84 visualizza tale linea." Print "Premere tasto per uscire." Do S = Inkey Loop Until S <> 0 Else Print Print "Input/Output (I/O)? "; Do R = Inkey() ' Attesa sospensiva di un tasto Loop Until R <> 0 Print Chr(r) R = R Or &H20 ' Converte in minuscolo If R = "i" Then Call Setp1234input() ' Setta tutti i port in input Print "Premere tasto per uscire" Print "Stato pin:" Do If V = "1" Then Vbit = P1.0 ' Pin 8 di CN4 End If If V = "2" Then Vbit = P1.3 ' Pin 6 di CN4 End If If V = "3" Then Vbit = P4.0 ' Pin 3 di CN4 End If If V = "4" Then If Scheda = Can_gm1 Then Vbit = P2.2 ' Pin 2 di CN4 End If If Scheda = Gmm_5115 Then Vbit = P4.1 ' Pin 5 di CN4 End If End If Print Vbit ; Chr(13); Waitms 200 S = Inkey Loop Until S <> 0 Else Do Print "Stato pin (0/1,2 esce): "; Do C = Inkey Loop Until C <> 0 Print Chr(c) C = C - 48 ' Converte da carattere numerico a valore If C = 0 Or C = 1 Then Vbit = C.0 If V = "1" Then P1.0 = Vbit ' Pin 8 di CN4 End If If V = "2" Then P1.3 = Vbit ' Pin 6 di CN4 End If If V = "3" Then P4.0 = Vbit ' Pin 3 di CN4 End If If V = "4" Then If Scheda = Can_gm1 Then P2.2 = Vbit ' Pin 2 di CN4 End If If Scheda = Gmm_5115 Then P4.1 = Vbit ' Pin 5 di CN4 End If End If End If Loop Until C = 2 End If End If Loop End ' '************************ Fine del programma *************************** ' ' '**************************** Procedure ******************************** ' ' Inizializza il demo Sub Init() Disable Interrupts ' Disabilita gli interrupts Ckcon = &H00 ' Setta X1 clock mode = standard mode Auxr = &H0C ' Seleziona Eram Su Area Dati Esterna Eecon = &H00 ' Disabilita Eeprom Del Micro End Sub ' Setta in input tutti i port Sub Setp1234input() Adcf = &H00 ' Setta tutto P1 come I/O P1 = &HFF ' Setta P1 in input C = P1 P2 = &HFF ' Setta P2 in input C = P2 P3 = &HFF ' Setta P3 in input C = P3 P4 = &HFF ' Setta P4 in input C = P4 End Sub