; ********************************************************************** ; * File S1DEB7.asm board: GPC 324+ETI 324 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 13.09.04 * ; ********************************************************************** ; DEB 01's example program of section 1, driven from a GPC 324 connected ; with an ETI 324. ; 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 shifts lighting of one ; LED in one direction or in the other one according to the status of ; T1 on eventual TIO 16 connected to CN4 of ETI 324. Practically if T1 is ; pressed, lighting LEDs shift to left, otherwise shift to right. ; To communicate to ETI 324 board you need to map it at address 50H. ; For cursor movement and positioning, are used some command sequences ; with ADDS Viewpoint standard (see GET51 manual). ; The connection is realized through one 26 pins flat cable that interface ; CN1 connector of GPC 324 and CN1 connector of ETI 324 and another 20 pin ; flat cable that connect CN3 of ETI 324 and CN15 of DEB 01. ; ; ; Addresses of on board peripherals ; PDA EQU 0FF50H ;82c55 address of data registers is calculated PDB EQU 0FF51H ;adding: FF00H (abaco I/O bus address for GPC 324), PDC EQU 0FF52H ;50H (mapping addrress for ETI 324) and 0..3 CNT EQU 0FF53H ;(offset for corresponding data register). ; ; Initialization of constant data ; INIT EQU 82H ;mode 0;port A and C in output,port B in input TXCHAR EQU 0DH ;variable with the value for the transmission PORTA EQU 08H ;internal memory address with portA value PORTB EQU 0AH ;internal memory address with portB value PORTC EQU 09H ;internal memory address with portC value DELAY EQU 11H ;variable used in delay subroutine ; ; 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 DPTR,#CNT ;initialization of PPI 82c55 as indicated in INIT MOV A,#INIT MOVX @DPTR,A ;write to 82C55's control register control word 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 INPORTB ;read the port B status ANL PORTB,#01H ;only T1 status of TIO 16 is checked, other keys are masked to 0 MOV A,PORTB CJNE A,#00H,RIGHT ;if T1 is not pressed, jump to right shifting LEFT: ACALL SHIFTLEFT ;left shifting AJMP CYCLE RIGHT: ACALL SHIFTRIGHT ;right shifting AJMP CYCLE ; ; Subroutine to show the acquire data on Port A ; OUTPORTAC: PUSH PSW ;save registers used by subroutine PUSH DPL PUSH DPH PUSH ACC MOV A,PORTA ;save the PORTA variable data on A MOV DPTR,#PDA ;load the Port A address MOVX @DPTR,A ;write data on port A MOV A,PORTC ;save the PORTC variable data on A MOV DPTR,#PDC ;load the Port C address MOVX @DPTR,A ;write data on Port C 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 ; ; Subroutine to acquire the reading data on port B ; INPORTB: PUSH PSW ;save registers used by subroutine PUSH DPL PUSH DPH PUSH ACC MOV DPTR,#PDB ;load the port B (TIO 16) address and MOVX A,@DPTR ;acquire its data MOV PORTB,A ;save it on proper variable POP ACC ;restore registers used by subroutine POP DPH POP DPL POP PSW RET ; ; Subroutine that move the lighting LED to left ; SHIFTLEFT: MOV R0,#08 ;execute eight cycle to shift port 0 MOV PORTA,#0FEH ;light the first LED of port 0 MOV PORTC,#0FFH ;keep turn off the LEDs of port1 SHIFTLEFT_A: MOV R2,#256 ;register used in delay subroutine ACALL DELAY100 ;100 usec delay ACALL OUTPORTAC ;visualize the PORTA contents MOV A,PORTA ;on DEB01's LEDs RL A ;shift the light LED left MOV PORTA,A DJNZ R0,SHIFTLEFT_A ;end of LEDs of Port 0 MOV R0,#08 ;execute other eight cycle to shift MOV PORTA,#0FFH ;turn off Port 0 MOV PORTC,#0FEH ;light the first LED of port1 SHIFTLEFT_C: MOV R2,#256 ACALL DELAY100 ACALL OUTPORTAC ;visualize the PORTC contents MOV A,PORTC RL A MOV PORTC,A DJNZ R0,SHIFTLEFT_C ;end of LEDs of Port 1 MOV PORTC,#0FFH ;turn off Port 1 RET ; ; Subroutine that move the lighting LED to right ; SHIFTRIGHT: MOV R0,#08 ;execute eight cycles to shift port 1 MOV PORTA,#0FFH ;keep turned off the LEDs fo port 1 MOV PORTC,#0FEH ;light the first LED of port 0 SHIFTRIGHT_C: MOV R2,#256 ACALL DELAY100 ;25 msec delay MOV A,PORTC ;on DEB01's LEDs RR A ;shift the light LED right MOV PORTC,A ACALL OUTPORTAC ;visualize the PORTA and PORTC contents DJNZ R0,SHIFTRIGHT_C ;reached last LED of Port 1 MOV PORTA,#7FH ;turn off Port 1 MOV PORTC,#0FFH ;light the first LED of port1 MOV R0,#08 ;execute other eight cycle to shift port 0 SHIFTRIGHT_A: MOV R2,#256 ACALL DELAY100 ;25 msec delay ACALL OUTPORTAC ;visualize the PORTA and PORTC contents MOV A,PORTA RR A MOV PORTA,A DJNZ R0,SHIFTRIGHT_A ;reached last LED of Port 0 MOV PORTA,#0FFH ;turn off Port 0 RET ; ; Subroutine for delay of 100 microseconds variable with R2 ; DELAY100: MOV DELAY,#120 ;120 cycles to obtain 100 usec delay DJNZ DELAY,$ ;defined by measure DJNZ R2,DELAY100 RET ; ; HEADING: DB 0CH,' NOTE: MAP ETI 324 AT ADDRESS 50H!' DB 1DH,' Shifts the lighting of one LED in one direction or the other one according',1DH,' to the status of T1 of eventual TIO 16.',00H END