' ********************************************************************** ' * File: gmbiot.bas - Rel. 1.1 con Bascom AVR IDE e LIB 1.11.7.4 * ' * Schede: GMB HR84 + GMM AM08 * ' * * ' * 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 16.01.04 * ' ********************************************************************** ' ' Questo Demo permette di utilizzare immediatamente le linee di I/O digitale TTL ' presenti su CN4. Alla partenza 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). ' ' 16.01.04 - Rel 1.1 By Graziano Gaiba per GMM AM08 ' ' 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: M8 ' HW Stack: almeno 64 ' Soft Stack: almeno 32 ' Framesize: almeno 64 ' ' '****************** Direttive del compilatore ************************** ' $regfile = "m8def.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 ' '****************** Dichiarazione delle procedure ********************** ' ' NESUNA PROCEDURA ' '************************* Programma main ****************************** ' Main: Print Chr(clrscr); ' Pulisce lo schermo Print "Demo 1.1 per GMB HR84 ds 100203" Print Do Print "Su CN4 questi pin sono I/O TTL:" Print Print "1) Pin 2" Print "2) Pin 3" Print "3) Pin 5" Print "4) Pin 6" 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 Ddrb = Ddrb And &HC5 ' Setta tutti i bit in input Print "Premere tasto per uscire" Print "Stato pin:" Do If V = "1" Then Vbit = Pinb.5 ' Pin 2 di CN4 End If If V = "2" Then Vbit = Pinb.3 ' Pin 3 di CN4 End If If V = "3" Then Vbit = Pinb.4 ' Pin 5 di CN4 End If If V = "4" Then Vbit = Pinb.1 ' Pin 6 di CN4 End If Print Vbit ; Chr(13); Waitms 200 S = Inkey() Loop Until S <> 0 Else Ddrb = Ddrb Or &H3A ' Setta tutti i bit in output 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 Portb.5 = Vbit ' Pin 2 di CN4 End If If V = "2" Then Portb.3 = Vbit ' Pin 3 di CN4 End If If V = "3" Then Portb.4 = Vbit ' Pin 5 di CN4 End If If V = "4" Then Portb.1 = Vbit ' Pin 6 di CN4 End If End If Loop Until C = 2 End If Loop End ' '************************ Fine del programma *************************** '