' ********************************************************************** ' ** Program name: PPO_AU.BAS - Version : 1.3 - 31 January 2001 ** ' ** Compilatore : BASCOM AVR, (IDE V.1.11.4.0, LIB 1.11.4.0) ** ' ** Board : K51-AVR ** ' ** 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: Graziano GAIBA ** ' ********************************************************************** ' ' This program activates sequentially one at a time all the 8 lines ' connected to IC1 (PCF8574A or 8574P, see constants declaration). ' ' '*********************************************************************** ' '********************* Compiler Directives ***************************** ' ' $regfile = "8515def.dat" ' AT90s8515 registers $romstart = &H0 ' code start address $crystal = 5529600 ' micro clock frequence $baud = 19200 ' baud rate Config Debounce = 50 ' time to wait to convalidate ' a key pressed ' Es: 10= 10ms, 50= 50ms ' ' *************************** PIN list AT90s8515 ************************** ' Config Sda = Portd.6 ' Pin 19 DATA signal for I2CBUS Config Scl = Portd.7 ' Pin 18 Clock signal for I2CBUS ' '********************* Constants declaration ****************************** ' Const Saa1064 = &H38 ' Slave address SAA1064 Const Wsaa1064 = &H70 ' Slave address SAA1064 in Write Const Rsaa1064 = &H71 ' Slave address SAA1064 in Read ' *********************** Addresses list for Saa1064 *********************** Const Ctb = 0 ' Ind. Control byte Const Dig1 = 1 ' Ind. Digit 1 Const Dig2 = 2 ' Ind. Digit 2 Const Dig3 = 3 ' Ind. Digit 3 Const Dig4 = 4 ' Ind. Digit 4 ' ********************************************************************** ' Commennt the declarations of the component not used, uncomment the ' other declarations Const Pcf8574 = &H3C ' Slave address PCF8574A Const Wpcf8574 = &H78 ' Slave address PCF8574A in Write Const Rpcf8574 = &H79 ' Slave address PCF8574A in Read 'Const Pcf8574 = &H24 ' Slave address PCF8574P 'Const Wpcf8574 = &H48 ' Slave address PCF8574P in Write 'Const Rpcf8574 = &H49 ' Slave address PCF8574P in Read ' '*********************** Variables declaration ************************* ' Dim Pout As Byte ' output lines status Dim X As Byte ' generic use Dim Valore As Byte ' value of counter ' '********************** Procedure declarations ************************* ' Declare Sub Iniz ' Peripherals initialization ' '*************************** Main program ******************************** ' Main: ' Delay for signals settling Waitms 1 Call Iniz ' initializations 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 Loop End ' '**************************** Program end ****************************** ' ' '**************************** Procedures ******************************* ' ' ********************** Peripherals initialization ******************** ' This procedure performs all the system initializations. ' Parameters: ' Input : nothing ' Output : nothing ' ************************************************************************ ' Sub Iniz ' Peripherals initialization 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 indifferente I2cwbyte 92 ' output to DY1 the char "o" I2cwbyte 28 ' output to DY2 the char2 "u" I2cwbyte 120 ' output to DY3 the char "t" I2cwbyte 0 ' DY4 off I2cstop End Sub '