' ********************************************************************** ' ** Program: DEMO_PPI.BAS - Version : 1.1 - 29 January 1999 ** ' ** Compiler: BASCOM LT (IDE V.1.20, LIB V.1.27) ** ' ** Card: GPC(r) 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 ** ' ** ** ' ** Developed by: Adriano Pedrielli ** ' ********************************************************************** ' ' This program manages the 24 TTL digital I/O lines driven by PPI 82c55 ' peripheral device and it drives the on board buzzer to genrate sound ' feed back during output setting. ' To visualize the lines status it is necessary to connect the CN2 of ' GPC(r) F2 to CN1 connector of TIO 16 or CN15 of DEB 01, through a 20 ' ways flat cable. ' '*********************************************************************** ' '********************** Compiler directive ****************************** ' $romstart = &H8050 ' Code area start address $ramstart = &HD000 ' Data area start address $ramsize = &H2800 ' Data area size = 10K $crystal = 11059200 ' Microcontroller clock frequency $baud = 9600 ' RS 232communication speed $large ' 16 bits addressing mode ' '******************** Constant declaration ***************************** ' Dim Cnt As Const &HFA03 ' Control and command register of 82c55 Dim Pda As Const &HFA00 ' Port A data register Dim Pdb As Const &HFA01 ' Port B data register Dim Pdc As Const &HFA02 ' Port C data register Buzzer Alias P1.2 ' Microprocessor pin rename ' '******************** Procedure declaration **************************** ' Declare Sub Vis_byte(v8bit As Byte) ' Shows each bit of a byte Declare Sub Show_dip1 ' Acquire DIP1 dip switch ' '******************** Variable declaration ***************************** ' Dim V8bit As Byte ' 8 bits variable for Vis_byte procedure Dim V1bit As Bit ' 1 bit variable for generic use Dim X As Byte , X1 As Byte ' 8 bits variable for generic use Dim X8bit As Byte , D8bit As Byte ' 8 bits variable for generic use ' '************************* Main program ******************************** ' Main: Waitms 1 ' Delay for signals adjustement Out Cnt , 130 ' Sets mode 0; port A and port C in output; ' port B in input because connected to DIP1 Out Pda , 255 ' Sets 8 lines of port A to 1 level Out Pdc , 255 ' Sets 8 lines of port C to 1 level Print Print " Demo program for PPI 82c55 peripheral device. V. 1.1 for GPC(r) F2" Print Print "The program sequentially enables one digital outputs on port A and port C," Print "at the same time it shows the status of port B that is connected to DIP1." Print "Each activation of the two ports, is annouced by an acoustics tone" Print Print Print " DIP1 dip switch" Print Print " 1 2 3 4 5 6 7 8" Do D8bit = 1 ' Sets first bit to enable For X1 = 1 To 8 ' Loops 8 times X8bit = Not D8bit ' Toggles all bits of variable Out Pda , X8bit ' Sets port A output lines Rotate D8bit , Left ' Shifts left one bit Show_dip1 ' Shows the DIP1 status and generates sound Next X1 ' End loop Out Pda , 255 ' Sets 8 lines of port A to 1 level D8bit = 1 ' Sets first bit to enable For X1 = 1 To 8 ' Loops 8 times X8bit = Not D8bit ' Toggles all bits of variable Out Pdc , X8bit ' Sets port C output lines Rotate D8bit , Left ' Shifts left one bit Show_dip1 ' Shows the DIP1 status and generates sound Next X1 ' End loop Out Pdc , 255 ' Sets 8 lines of port A to 1 level Loop ' Endless loop End ' '************************ Main program end ***************************** ' ' '*************************** Procedure ********************************* ' ' Procedure that shows the DIP1 dip switch status ' Input parameter: none ' Output parameter: none Sub Show_dip1 V8bit = Inp(pdb ) ' Acquires port B value Vis_byte (v8bit) ' Shows all the 8 bit status Print Chr(13); ' Places cursor at the begin of the row Waitms 255 ' Delays 255 ms Sound Buzzer , 200 , 100 ' Generates a 2 KHz frequency signal for 100ms Buzzer = 1 ' Sets to 1 the buzzer line End Sub ' ' Procedure that shows each bit status of a byte ' Input parameter: v8bit = byte = value to be displayed as bit status ' Output parameter: none Sub Vis_byte (v8bit As Byte ) For X = 1 To 8 ' Shows 8 times the current bit V1bit = V8bit And &H01 ' Masks bit 0 If V1bit = 0 Then ' Tests current bit status Print " On " ; ' If status=0 shows On Else Print " Off" ; ' If status=1 shows Off End If Rotate V8bit , Right ' Shift right one bit Next X End Sub