' ********************************************************************** ' ** Program: gmbade.BAS - Version : 1.1 - 15 June 2005 ** ' ** Compiler : Bascom AVR IDE - LIB 1.11.7.4 ** ' ** Board : GMB HR168 and GMM AM32 ** ' ** Society: 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 ** ' ** Written by: Graziano Gaiba ** ' ********************************************************************** ' ' 15.06.05 - Rel 1.1 By Graziano Gaiba ' This demo shows continuously on the console the combination read from ' analog input on pin 8 of CN7 on GMB HR 168, corresponding to ADC7 of micro. ' External Vref generated by GMB HR 168 is used. ' ' Compiled file is smaller than 2048 bytes, so it can becompliled with free ' demo of BASCOM AVR. ' ' ' !!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ' In menu Options | Compiler | Chip, set: ' ' Chip: M32 ' HW Stack: at least 64 ' Soft Stack: at least 32 ' Framesize: at least 64 ' ' $regfile = "m32def.dat" $crystal = 7372800 $baud = 19200 ' ' ********************* Constans declarations ************************* ' 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 ' ' ********************* Variables declarations ************************ ' Dim I As Byte , Conv_h As Byte , Conv_l As Byte Dim A As Eram Byte At 1023 ' '*********** Configuration of internal devices and interrupt ************ ' ' Configured AD converter for single conversion, use internal Vref and ' automatic prescaler. ' Config Adc = Single , Prescaler = Auto , Reference = Internal ' ' '****************** Procedures declartion ********************** ' Declare Sub Init() ' Initializtion Declare Sub Check_ready() ' '*************************** Main program ****************************** ' Main: Call Init() ' Initialize module Print Chr(clrscr); ' Clears the screen Print "Demo 1.1 for GMM AM32 + GMB HR168" Print Call Check_ready() Do Print "A/D converter demo" Print Print "Analog signal present on pin 8 of CN7 is converted." Print "Connecting J11 in 1-2 the signal can range from 0 to 2.5 V," Print "connecting J11 in 2-3 the signal can range from 0 to 10 V." Print "External 2.5 V reference voltage generated by GMB HR168 is used." Print "POLLING" Print Print "CH07" Start Adc ' Enables A/D Converter Do Admux = 7 ' Selects channel ADC7 ' and external Vref Adcsr.adsc = 1 ' Begin conversion Do Loop Until Adcsr.adif = 1 ' Waits for conversion end Adcsr.adif = 1 ' Resets end-of-conversion flag Conv_l = Adcl ' Always read least significant byte Conv_h = Adch Print Hex(conv_h) ; Hex(conv_l) ; ' Prints conversion Print Chr(cret); ' Carriage return Waitms 100 ' Delay for transmission I = Inkey() Loop Until I <> 0 Stop Adc Loop End ' ' *************************** Program end ****************************** ' ' ' **************************** Procedures ****************************** ' ' Initialize demo Sub Init() ' No initialization End Sub ' ' ' Check for hardware ready ' Sub Check_ready() Test: If A = &H55 Then Goto L2 Else Goto Test End If L2: End Sub