' ********************************************************************** ' ** Program name: PPOF2.BAS - Version : 1.1 - 22 May 2000 ** ' ** Compiler : BASCOM 8051, (IDE V.1.0.0.20, LIB V.1.20) ** ' ** Board : K51-AVR and GPC F2 ** ' ** Firm: 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: Adriano Pedrielli ** ' ********************************************************************** ' ' This program activates sequentially one at a time all the 8 lines ' connected to IC1 (PCF8574A or 8574P, see constants declaration), through ' two TTL lines driven by the family 51 microcontroller-based GPC F2 ' board. ' This program is controlled through the RS 232 serial line so it is essential ' to connect a free COM port on the PC to the connector CN3 of GPC(r) F2. ' Configure the BASCOM 8051 terminal using menu Option/Communication, select ' the COM port and set baud rate to 9600, parity to none, databits to 8 and ' stopbits to 1. ' ' Perform the following connections : ' GPC F2 K51 AVR ' +5Vdc (pin15 CN3) ----> +5Vdc (pin1 CN6) ' Gnd (pin16 CN3) ----> Gnd (pin2 CN6) ' T0 P3.4 (pin3 CN3) ----> SD (pin7 CN6) ' T1 P3.5 (pin1 CN3) ----> SC (pin8 CN6) ' ' Before compiling set in menu Option/Compiler/Misc/ : ' Byte End 5F ' '*********************************************************************** ' '********************** Compiler directives **************************** ' $regfile = "REG51.DAT" ' list of CPU registers $romstart = &H8050 ' code start address ' &H8050 for MO52 Rel.1.1 in RAM IC8 ' &H0000 for EPROM withput RAM IC8 $ramstart = &HD000 ' add. of variables external RAM $ramsize = &H2800 ' assign 10K of external RAM ' to variables $crystal = 11059200 ' CPU clock frequence $baud = 9600 ' RS-232 communication speed $large ' 16 bit addressing ' ' ******************************* 8xc51 PIN list *********************** ' Config Sda = P3.4 ' line P3.4 or T0 (pin 3 of CN3) ' on GPC(r) F2 is Data signal. Config Scl = P3.5 ' line P3.5 or T1 (pin 1 of CN3) ' on GPC(r) F2 is Clock signal. Buz Alias P1.2 ' Pin 3 of GPC F2 microcontroller ' is connected to the on board ' buzzer. Const Cler = 12 ' clear screen code Const Bel = 7 ' Bell code ' '********************* Constants declaration *************************** ' Dim Saa1064 As Const &H38 ' Slave address SAA1064 Dim Wsaa1064 As Const &H70 ' Slave address SAA1064 in Write Dim Rsaa1064 As Const &H71 ' Slave address SAA1064 in Read '****************** Addresses list for Saa1064 ************************* Dim Ctb As Const 0 ' Address Control byte Dim Dig1 As Const 1 ' Address Digit 1 Dim Dig2 As Const 2 ' Address Digit 2 Dim Dig3 As Const 3 ' Address Digit 3 Dim Dig4 As Const 4 ' Address Digit 4 ' ********************************************************************** ' Comment the declaration of the component not used, uncomment the other ' declaration ' Dim Pcf8574 As Const &H3C ' Slave address PCF8574A Dim Wpcf8574 As Const &H78 ' Slave address PCF8574A in Write Dim Rpcf8574 As Const &H79 ' Slave address PCF8574A in Read 'Dim Pcf8574 As Const &H24 ' Slave address PCF8574P 'Dim Wpcf8574 As Const &H48 ' Slave address PCF8574P in Write 'Dim Rpcf8574 As Const &H49 ' Slave address PCF8574P in Read ' '*********************** Variables declaration ************************* ' Dim Pout As Byte ' value for output signals Dim X As Byte ' general purpose Dim Valore As Byte ' counter Dim T As Byte ' code of key pressed ' '********************* Procedures declaration ************************** ' Declare Sub Iniz ' Peripherals initialization ' '*************************** Main program ****************************** ' Main: ' Delay for signals settling Waitms 1 Call Iniz ' initializations Do Do Valore = 1 ' starting value For X = 1 To 7 ' cycle initialization Pout = Not Valore ' complement the value I2csend Wpcf8574 , Pout ' set the outputs Valore = Valore * 2 ' left shift of the bits Waitms 255 ' delay Next X For X = 1 To 7 ' cycle initialization Pout = Not Valore ' complement the value I2csend Wpcf8574 , Pout ' set the outputs Valore = Valore / 2 ' right shift of the bits Waitms 255 ' delay Next X T = Inkey ' read a char from serial port Loop Until T <> 0 ' exit if received a character If T = 27 Then ' ESC key has been pressed Exit Do ' exit from loop Else Print Chr(bel); ' key non valid End If Loop Ljmp 0 ' exit and restart monitor End ' '*************************** Programma end ****************************** ' ' '**************************** Procedures ******************************** ' ' ********************** Peripherals initialization ******************** ' This procedure performs all the system initializations. ' Parameters: ' Input : nothing ' Output : nothing ' ************************************************************************ ' Sub Iniz ' Peripherals initialization Print Chr(cler); ' clear screen Print "Demo K51-AVR 8 output to IC1(PCF8574A or 8574P) through GPC F2"; Print " rel.1.1 22/05/2000" Print Print "Press ESC to exit" Do I2creceive Rsaa1064 , Valore ' Read the status register Loop Until Valore = 0 ' Wait for SAA1064 to turn on I2cstart ' Start sequence for I2CBUS I2cwbyte Wsaa1064 ' Communicate the Slave address I2cwbyte Ctb ' Point to control register I2cwbyte &B00100111 ' bit0 =1 dynamic mode ' bit1 =1 digit 1+3 not blanked ' bit2 =1 digit 2+4 not blanked ' bit3 =0 no test segment ' bit4 =0 no 3mA segment current ' bit5 =1 6mA segment current ' bit6 =0 no 12mA segment current ' bit7 =0 indifferent I2cwbyte 92 ' set DY1 "o" I2cwbyte 28 ' set DY2 "u" I2cwbyte 120 ' set DY3 "t" I2cwbyte 0 ' set DY4 off I2cstop End Sub '