' ********************************************************************** ' ** Program name: S1DEB2.BAS - Version : 1.1 - 02 June 1999 ** ' ** Compiler : BASCOM LT, (IDE V.1.20, LIB V.1.27) ** ' ** Board : GPC(r) 552 ** ' ** 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 shows on the PC screen the status of port A and C lines in ' binary format. ' To achieve the visualization of the lines, you should connect the CN2 ' connector of GPC(r) 552 board to the CN15 connector of DEB(r) 01 board by ' a 20-pin flat cable. ' '************************ Compiler Directives ******************************* ' $romstart = &H8050 ' start address of machine code $ramstart = &HD000 ' start address of data area $ramsize = &H2800 ' 10k of data area $crystal = 22118400 ' clock of microcontroller $baud = 19200 ' RS-232 baud rate $large ' 16 bit addressing mode ' '************************** Constant declarations **************************** ' Dim Pda As Const &HFFF8 ' port A data register Dim Pdb As Const &HFFF9 ' port B data register Dim Pdc As Const &HFFFA ' port C data register Dim Cnt As Const &HFFFB ' control register ' '************************** Variable declarations **************************** ' Dim Port As Byte ' Stores the port status Dim V8bit As Byte , C8bit As Byte ' General purpose variables Dim R8bit As Byte ' '************************** Procedure declarations **************************** ' Declare Sub Stampabits(v8bit As Byte)' Prints bits of its input parameter in ' binary format (makes no carriage return) Waitms 1 ' Delay for signals settling ' '***************************** Main Program ********************************** ' Print " Demonstration program 2 for section 1 of DEB(r) 01 board" Print : Print " Shows on PC screen the status of port A and C lines in binary format." Print : Print " Running..." Print Out Cnt , &B10011011 ' Configures port A, B and C for input Print "Port A Port C" ' Prints the mask Do Port = Inp(pda) ' Reads port A Call Stampabits(port) ' Prints its value in binary formay Print " " ; Port = Inp(pdc) ' Reads port C Call Stampabits(port) ' Prints its value in binary formay Print Chr(13) ; ' Carriage return Waitms 250 ' Delay to get few prints per second Loop End ' '*************************** End of Main program ***************************** ' ' '****************************** Procedures ********************************** ' ' This procedure prints its 8 bits parameter as a "1"/"0" chars sequence. ' It makes no carriage return. ' Input parameter: ' V8bit byte Value to be printed in binary format ' Output parameters: ' None Sub Stampabits(v8bit As Byte) For C8bit = 1 To 8 R8bit = V8bit And &H80 ' Read the most significant bit of V8bit If R8bit = 0 Then ' If the button on DEB(r) is pressed Print "0" ; ' prints 0 Else ' else Print "1" ; ' prints 1 End If ' this because the buttons work in negated logic Rotate V8bit , Left ' Moves the next bit of V8bit into its ' most significant bit Next C8bit ' Repeats 8 times End Sub