; ********************************************************************** ; * File S1DEB5.asm board: GPC 553 with SXA51 * ; * GRIFO(R) via Dell'Artigiano 8/6 40016 S. Giorgio di Piano (BO) * ; * Tel. +39 051 892052 Fax. +39 051 893661 * ; * http://www.grifo.it http://www.grifo.com * ; * by Alessio Francesconi 28.09.04 * ; ********************************************************************** ; DEB 01's example program of section 1, driven from a GPC 553. ; This section is composed by 16 keys conncted to 16 LEDs: ; the pressure of one or more of these keys, sets the logic state 0 on ; the line and the relative LED is lit by hardware. ; This program has to comunicate with PC and to writes the status of ; Port 1 (Port 1 of GPC 553), on Port 0 (Port 4 of GPC 553) if the dip 1 ; of user dip switch is OFF, otherwise writes on Port 0, the complemented ; status if the dip 1 is ON. ; For cursor movement and positioning, are used some command sequences ; with ADDS Viewpoint standard (see GET51 manual). ; The connection is realized through one 20 pins flat cable that interface ; CN5 connector of GPC 553 and CN15 connector of DEB 01. ; ; Addresses of on board peripherals ; PORT1 EQU 090H ;80c552 data register of port 1 PORT4 EQU 0C0H ;80c552 data register of port 4 DSW1 EQU 0FFFCH ;80c552 data register of dip switch ; ; Initialization of constant data ; TXCHAR EQU 0DH ;variable with the value for the transmission FPORT EQU 08H ;internal memory address with port4 value DIPS EQU 0AH ;internal memory address with dip switch value SECPORT EQU 09H ;internal memory address with port1 value ; ; Start of main program ; ORG 2050H ;beginning of executable part program MAIN: MOV SP,#2FH ;initialize the first free location pointer of the stack MOV PORT1,#0FFH ;set port 1 GPC 553 (port 1 DEB 01) in input MOV PORT4,#00H ;set port 4 GPC 553 (port 0 DEB 01) in output CLR RS0 ;select the registers bank 0 (00H-07H) CLR RS1 ACALL SERIAL MOV DPTR,#HEADING ;print to monitor the "HEADING" string ACALL STRING ; CYCLE: ACALL INDSW1 ;read the dip switch status ANL DIPS,#01H ;only dip 1 status is checked, other dips are masked to 0 MOV A,DIPS CJNE A,#00H,COMPL ;if dip 1 is OFF, jump to complemented setting ACALL INPORT1 ;read the Port 1 status MOV FPORT,SECPORT ;transfer the SECPORT value on FPORT variable ACALL OUTPORT0 ;write the normal bit on Port 0 AJMP CYCLE COMPL: ACALL INPORT1 ;read the Port 1 status MOV A,SECPORT CPL A ;complement of SECPORT value MOV FPORT,A ;transfer the SECPORT value on FPORT variable ACALL OUTPORT0 ;write the complemented bit on Port 0 AJMP CYCLE ; ; Subroutine to acquire the reading data on dip switch ; INDSW1: PUSH PSW ;save registers used by subroutine PUSH DPL PUSH DPH PUSH ACC MOV DPTR,#DSW1 ;load the dip switch address and MOVX A,@DPTR ;acquire its data MOV DIPS,A ;save it on proper variable POP ACC ;restore registers used by subroutine POP DPH POP DPL POP PSW RET ; ; Subtoutine to acquire the reading data on Port 1 ; INPORT1: PUSH PSW ;save registers used by subroutine PUSH DPL PUSH DPH PUSH ACC MOV A,PORT1 ;load port 1 address MOV SECPORT,A ;and put it on SECPORT POP ACC ;restore registers used by subroutine POP DPH POP DPL POP PSW RET ; ; Subroutine to show the acquire data on Port 0 ; OUTPORT0: PUSH PSW ;save registers used by subroutine PUSH DPL PUSH DPH PUSH ACC MOV A,FPORT ;load the value to represent on ACC MOV PORT4,A ;and to put it on port 0 of DEB 01 POP ACC ;restore registers used by subroutine POP DPH POP DPL POP PSW RET ; ; Serial initialization procedure ; SERIAL: PUSH PSW ;save PSW MOV SCON,#50H ;select mode 1, active reception MOV TH1,#253 ;initialize to 19200 baud ANL PCON,#7FH ;reset the bit 7 of PCON (SMOD) POP PSW ;restore PSW RET ; ; Serial transmission of a string contained in external data memory ; STRING: PUSH PSW ;save registers used by subroutine PUSH ACC PUSH TXCHAR STRINGLOOP: MOVX A,@DPTR ;load into A the memory contents pointed by DPTR JZ ENDSTRING ;if the last reading character is void (00H),jump to end MOV TXCHAR,A ;put the current character into the variable for the transmission ACALL TRASMSER ;transmit the character INC DPTR ;increase the pointer to be ready SJMP STRINGLOOP ;for the following character ENDSTRING: POP TXCHAR ;restore registers used by subroutine POP ACC POP PSW RET ; ; Serial transmission's procedure ; TRASMSER: PUSH PSW ;save PSW TRASM1: JBC TI,TRASM2 ;jump to TRASM2 if TI = 1 and reset TI SJMP TRASM1 ;jump to TRASM1 because TI = 0 ;and serial is still in transmission TRASM2: MOV SBUF,TXCHAR POP PSW ;restore PSW RET ; ; HEADING: DB 0CH,' Writes to port 0 the status complemented of Port 1 if switch 1 of user',1DH,' dip switch is OFF, otherwise write the status not complemented.',00H END