' ********************************************************************** ' ** Program: gmbdae.BAS - Version : 1.1 - 28 January 2004 ** ' ** Compiler : Bascom AVR IDE - LIB 1.11.7.4 ** ' ** Scheda : GMB HR84 and GMM AM08 ** ' ** 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 ** ' ** sales@grifo.it tech@grifo.it grifo@grifo.it ** ' ** ** ' ** Written by: Graziano Gaiba ** ' ********************************************************************** ' ' Rel. 1.1 28.01.04 - By Graziano Gaiba ' ' This demo uses section 0 of Mini Module PCA to generate, on CN4, ' a PWM signal with preset frequency and duty cycle programmable in ' percent by console. Such signal, connected to an opportune ' intergrating circuit (RC network, operational amplifire with capacitor ' on feedback, etc.) allows to obtain an anlog signal like the one of a ' D/A. ' Demo execution depends on which Mini Module is used and serial line ' configuration. ' ' 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: M8 ' HW Stack: at least 64 ' Soft Stack: at least 32 ' Framesize: at least 64 ' ' $regfile = "m8def.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 ' '*********** 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 ' '*************************** Main program ****************************** ' Main: Call Init() ' Intializes modulo Print Chr(clrscr) ' Clears the screen Do Print "A/D converter demo" Print Print "External 2.5 V Vref voltage is used. It is generated on board by GMB HR84." 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