; ********************************************************************** ; * File S1DEB2.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 the PC and visualize on monitor ; the decimal code (from 0 to 255) of the status of both ports: ; practically, pressing the DEB 01 keys, you can modify the represented ; status. ; 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 ; ; Initialization of constant data ; RXCHAR EQU 0CH ;variable with the value received on serial port TXCHAR EQU 0DH ;variable with the value for the transmission FPORT EQU 08H ;internal memory address with port4 value SECPORT EQU 09H ;internal memory address with port1 value UNITY EQU 0EH ;variable with the value of unity TENS EQU 0FH ;variable with the value of tens HUNDREDS EQU 10H ;veriable with the value of hundreds RECEIVED EQU 01H ;reception bit of serial port:1 for received chr,0 for nothing ; ; 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,#0FFH ;set port 4 GPC 553 (port 0 DEB 01) in input CLR RS0 ;select the registers bank 0 (00H-07H) CLR RS1 ACALL SERIAL MOV DPTR,#HEADING ;print to monitor the "HEADING" string ACALL STRING ; ; Start of principal program cycle ; CYCLE: ACALL INPORTS ;read the ports 4 and 1 MOV TXCHAR,#1AH ;move cursor up ACALL TRASMSER MOV A,FPORT ACALL ASCII ;transform to ASCII code the FPORT value ACALL TRASCII ;transmission of FPORT value MOV TXCHAR,#0AH ;move cursor down ACALL TRASMSER MOV A,SECPORT ACALL ASCII ;transform to ASCII code the SECPORT value ACALL TRASCII ;transmission of SECPORT value SJMP CYCLE ;jump to the reading of ports of DEB 01 ; ; Procedure that acquire the value of ports 0 and 1 ; INPORTS: PUSH PSW ;save the registers used by procedure PUSH DPL PUSH DPH PUSH ACC MOV A,PORT4 ;load port 4 address MOV FPORT,A ;and put it on FPORT MOV A,PORT1 ;load port 1 address MOV SECPORT,A ;and put it on SECPORT POP ACC ;restore the registers used by procedure 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 this procedure 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 procedure 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 ; ; Procedure that transform the acquire code from ports to decimal code ; ASCII: PUSH PSW ;save the registers used by procedure PUSH ACC PUSH B MOV B,#100 DIV AB ;divide A to 100 to determine hundreds ADD A,#30H ;add to hundreds 30H to trensform it in ASCII code MOV HUNDREDS,A ;save the hundreds MOV A,B ;reload on A the value MOV B,#10 DIV AB ;divide A to 10 to determine tens ADD A,#30H ;add to tens 30H to transform it in ASCII code MOV TENS,A ;save the tens MOV A,B ;reload on A the value ADD A,#30H ;add to unity 30H to transform it in ASCII code MOV UNITY,A ;save the unity POP B ;restore the register used by procedure POP ACC POP PSW RET ; ; Procedure for sending value on screen through serial port ; TRASCII: PUSH PSW ;save the registers used by procedure PUSH ACC PUSH TXCHAR MOV A,HUNDREDS ;check the hundreds are different to '0' CLR F0 ;reset the flag F0 MOV TXCHAR,A ;hundreds in TXCHAR CJNE A,#48,ASCII1 ;if they are different jump to ASCII1 MOV TXCHAR,#20H ;otherwise send a space SETB F0 ;show that hundreds were equal to '0' ASCII1: ACALL TRASMSER MOV A,TENS ;check the tens are different to '0' MOV TXCHAR,A ;tens in TXCHAR CJNE A,#48,ASCII2 ;if they are different send the tens JNB F0,ASCII2 ;otherwise if hundreds were to '0' MOV TXCHAR,#20H ;send a space ASCII2: ACALL TRASMSER MOV TXCHAR,UNITY ;transmit the unity ACALL TRASMSER MOV TXCHAR,#08H ;transmit three shift to left ACALL TRASMSER ACALL TRASMSER ACALL TRASMSER POP TXCHAR ;restore the register used by procedure POP ACC POP PSW RET ; ; HEADING: DB 0CH,' Writes on the monitor of the -development system- the status of both the ports.',1DH,1DH,'Port 0: ',1DH,'Port 1: ',00H END