' ********************************************************************** ' ** Program : gmbi2cge.bas - Version : 1.1 - 24 June 2003 ** ' ** Compiler : BASCOM 8051 DEMO, (IDE and LIB V.2.0.11.0) ** ' ** Board : GMB HR84 with GMM 5115 ** ' ** Corporate: 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 ** ' ********************************************************************** ' ' These demos allow to communicate to I2C BUS devices connected to CN3. ' According to the Mini Module installed, it is possible to read or write bytes ' at any slave address and location address input by console. In detail, when ' reading the byte read is visualized and when writing the byte input is sent. ' ' ' 24.06.2003 by Graziano Gaiba ' ' '****************** Compiler directives ************************** ' ' Set to 80h internal memory limit by: ' Options/Compiler/Misc $regfile = "grifo_mm.dat" $romstart = &H0 ' start address of code for FLASH $ramstart = &H0 ' start address of external RAM $ramsize = &H100 ' 256 bytes of external RAM $crystal = 14745600 ' Microcontroller clock $baud = 19200 ' RS-232 baud rate '$large ' 16 bit addressing for jumps ' ' Config Sda = P2.0 ' I2C serial DATA Config Scl = P2.1 ' I2C serial CLK ' ' '****************** Variables declaration ********************** ' Dim Valore As Byte , I As Byte ' Generic use Dim Slave As Byte ' Slave address Dim Buf(30) As Byte ' Data to send and receive Dim Inviare As Byte ' Number of data to send Dim Ricevere As Byte ' Number of data to receive ' '************************** Main program ****************************** ' Main: Waitms 1 ' Delay for signals settling ' Initialize demo Disable Interrupts ' Disabiles interrupts Auxr = &H0C ' Selects Eram on external data area Eecon = &H00 ' Disables Eeprom of Micro Adcf = &H00 ' Sets port 1 as input Print Chr(12) Print "This demo has been made to run only on a GMM 5115." Print "Proceed only if you have the correct Mini Module!" Print "Press a key if you want to continue..." Do Valore = Inkey Loop Until Valore <> 0 Do Print Chr(12) Print "Demo I2C BUS on CN3 of GMB HR84" Print Print "1) Write" Print "2) Read" Print Print "Select: " Do Valore = Inkey Loop Until Valore = "1" Or Valore = "2" Print Input "Slave address (in decimal): " , Slave Input "Number of data to receive: " , Ricevere Input "Number of data to send: " , Inviare If Inviare <> 0 Then For I = 1 To Inviare Print "data " ; I ; ") "; Input Buf(i) Next I End If Select Case Valore Case "1" : I2csend Slave , Buf(1) , Inviare Case "2": I2creceive Slave , Buf(1) , Inviare , Ricevere End Select If Ricevere <> 0 Then Print "Data received:" For I = 1 To Ricevere Print "data " ; I ; ") " ; Buf(i) Next I End If Print "Hit a key to continue..." Do Valore = Inkey Loop Until Valore <> 0 Loop End ' '************************ Program end *************************** '