' ********************************************************************** ' * File: gmbiot.bas - Rel. 1.1 con Bascom AVR IDE e LIB 1.11.7.4 * ' * Schede: GMB HR168 + GMM AM32 * ' * 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 * ' * by Graziano Gaiba del 10.06.05 * ' ********************************************************************** ' ' 10.06.05 - Rel 1.1 By Graziano Gaiba ' Questo Demo permette di utilizzare immediatamente le linee di I/O digitale TTL ' presenti su CN7. 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 o della GMB HR168, ' la gestione avviene tramite questa periferica. ' ' Il file compilato non supera i 2048 bytes, quindi puo' essere ' compilato con il demo gratuito di BASCOM AVR. ' ' ' !!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ' Nel menu Options | Compiler | Chip, impostare: ' ' Chip: M32 ' HW Stack: almeno 64 ' Soft Stack: almeno 32 ' Framesize: almeno 64 ' ' '****************** Direttive del compilatore ************************** ' $regfile = "m32def.dat" $crystal = 7372800 $baud = 19200 ' '****************** 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 ' '****************** Dichiarazione delle variabili ********************** ' ' Uso generico Dim R As Byte , C As Byte , V As Byte , T As Byte Dim S As Byte Dim Vbit As Bit Dim A As Eram Byte At 1023 ' '****************** Dichiarazione delle procedure ********************** ' Declare Sub Check_ready() ' '************************* Programma main ****************************** ' Main: Print Chr(clrscr); ' Pulisce lo schermo Print "Demo 1.1 per GMM AM32 + GMB HR168" Print Call Check_ready() ' Verifica scheda pronta Do Print "Su CN7 questi pin sono I/O TTL:" Print Print "1) Pin 2" Print "2) Pin 6" Print "3) Pin 8" Print Print "SCELTA: "; Do V = Inkey() Loop Until V <> 0 Print Chr(v) Print Do Print "Input/Output (I/O)? " ; R = Waitkey() R.5 = 1 ' Trasforma in minuscolo Loop Until R = "i" Or R = "o" Print Chr(r) If R = "i" Then Ddra.7 = 0 ' Setta tutti i bit in input Ddrd.4 = 0 Ddrd.5 = 0 Print "Premere tasto per uscire" Print "Stato pin:" Do If V = "1" Then Vbit = Pind.4 ' Pin 2 di CN7 End If If V = "2" Then Vbit = Pind.5 ' Pin 6 di CN7 End If If V = "3" Then Vbit = Pina.7 ' Pin 8 di CN7 End If Print Vbit ; Chr(13); Waitms 200 S = Inkey() Loop Until S <> 0 Else Ddra.7 = 1 ' Setta tutti i bit in output Ddrd.4 = 1 Ddrd.5 = 1 Do Print "Stato pin (0/1; 2 esce): "; C = Waitkey() Print Chr(c) C = C - "0" ' Converte in numero If C <> 2 Then Vbit = C.0 If V = "1" Then Portd.4 = Vbit ' Pin 2 di CN7 End If If V = "2" Then Portd.5 = Vbit ' Pin 6 di CN7 End If If V = "3" Then Porta.7 = Vbit ' Pin 8 di CN7 End If End If Loop Until C = 2 End If Loop End ' '****************************************************************************** '* Procedure di uso generico * '****************************************************************************** ' ' '************************ Fine del programma *************************** ' ' ' ' Controlla che la scheda sia pronta ' Sub Check_ready() Test: If A = &H55 Then Goto L2 Else Goto Test End If L2: End Sub