; ********************************************************************** ; * File S1DEB1.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 10.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 through serial line ; (asynchronous com., 8 bit per char, 1 stop bit, no parity, baud rate=19200), ; and to active the LEDs on port 0 of DEB 01, the binary sequence ; of hexadecimal data (from 0 to F) admitted through the keyboard ; of development system. This hexadecimal code is represented on ; monitor too. ; 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 8BH ;mode 0,port A output set ,port B e C input set RXCHAR EQU 0CH ;variable that contain the value arrived on serial port TXCHAR EQU 0DH ;variable that contain the value for the transmission PORTA EQU 08H ;internal memory address that contain the portA value RECEIVED EQU 01H ;reception bit of serial port:1 for received bit,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 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 REC_SER ;start here the cycle that call the procedure ;of serial reception JNB RECEIVED,CYCLE MOV TXCHAR,RXCHAR ;put in transmission variable the value received ACALL TRASMSER MOV PORTA,TXCHAR ;put on port A the read data if this one ACALL PORTLED ;is an hexadecimal value MOV TXCHAR,#08H ;cursor come back to left of one character ACALL TRASMSER SJMP CYCLE ; ; 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 ; ; Waithing procedure for serial reception ; REC_SER: PUSH PSW ;save register used by this procedure PUSH 0 PUSH 1 MOV R0,90 ;90 repetition of cycle delay MOV R1,250 ;250 repetition of cycle of reception control LOOP0: JBC RI,LOOP1 ;jump to LOOP1 if RI = 1 and reset RI DJNZ R0,$ ;decrease R0 and jump the same instruction DJNZ R1,LOOP0 ;decrease the contained value in R1 ;jump to LOOP0 if in R1 there isn't one 0 CLR RECEIVED ;if I don't receive nothing I reset RECEIVED SJMP END_REC ;jump to the end of procedure LOOP1: MOV RXCHAR,SBUF ;save the received value on serial in RXCHAR SETB RECEIVED ;set to 1 the reception bit END_REC: POP 1 ;restore registers used by procedure POP 0 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 write the serial data on port 0 of DEB 01 ; PORTLED: PUSH PSW ;save registers used by this procedure PUSH DPL PUSH DPH PUSH ACC PUSH 0 MOV A,PORTA ;load into A value to check CJNE A,#30H,NUM1 ;if A>=0 (30H) reset C,if A<0 set C NUM1: JC ENDOUT ;if A<0 the character isn't an hexadecimal one CJNE A,#39H,NUM2 ;if A<9 (39H) set C,if A>=9 reset C SETB C NUM2: JNC COUNT1 ;if A>9 jump to COUNT1 MOV R0,#48 ;Example: ascii character 1: 49: 49 - 48 = 1 SJMP LEDOUT COUNT1: CJNE A,#41H,HEXCHAR1 ;if A>=A(41H) reset C,if A=F reset C SETB C HEXCHAR2: JNC COUNT2 ;if A>F jump to COUNT2 MOV R0,#55 ;Example:ascii character A: 65: 65 - 55 = 10 SJMP LEDOUT COUNT2: CJNE A,#61H,LETTER1 ;if A>=a(61H) reset C,if A=f reset C SETB C LETTER2: JNC ENDOUT ;if A>f jump to CLEARH MOV R0,#87 ;Example:ascii character: 97: 97 - 87 = 10 LEDOUT: MOV A,PORTA ;load into A value to manage CLR C SUBB A,R0 ;to transform ASCII code of letters CLR C CPL A ;invert the bits to visualize,active leds MOV PORTA,A ;send data on port A ACALL OUTPORT ENDOUT: POP 0 ;restore registers used by procedure POP ACC POP DPH POP DPL POP PSW RET ; ; Procedure that put PORTA's variable data on port0 ; OUTPORT: PUSH PSW ;save registers used by procedure PUSH DPL PUSH DPH PUSH ACC MOV A,PORTA ;put PORTA's variable into ACC MOV DPTR,#PDA ;load PORTA's address MOVX @DPTR,A POP ACC ;restore registers by procedure POP DPH POP DPL POP PSW RET ; ; HEADING: DB 0CH,' NOTE: MAP ETI 324 AT ADDRESS 50H!' DB 1DH,' Writes to port 0 the hexadecimal code of the key pressed on the keyboard of',1DH,' the - development system - : ',0 END