; ;Configuration and test program for the S100Computers 3P+2s IO Board ;This program initilizes the Z8030 SCC's,and 8255 chips and tests them ; ; Author John Monahan (S100Computers.com) 10/9/2023 ; ; V0.1 10/9/2023 ;initial program ; SCROLL EQU 01H ;Set scrool direction UP. BELL EQU 07H SPACE EQU 20H TAB EQU 09H ;TAB ACROSS (8 SPACES FOR SD-BOARD) CR EQU 0DH LF EQU 0AH FF EQU 0CH QUIT EQU 11H ;Turns off any screen enhancements (flashing, underline etc). NO_ENHANCEMENT EQU 17H ;Turns off whatever is on FAST EQU 10H ;High speed scrool ESC EQU 1BH DELETE EQU 7FH BACKS EQU 08H CLEAR EQU 1AH ;TO CLEAR SCREEN RST7 EQU 38H ;RST 7 (LOCATION FOR TRAP) NN EQU 0H ;[I] INITIAL VALUE SOH EQU 1 ; For XModem etc. EOT EQU 4 ACK EQU 6 NAK EQU 15H ; PORT ASSIGNMENTS OF THE ZILOG SCC CHIP ; ACTL EQU 051H ; CHANNEL 0 CONTROL ;also update Signon MSG below ADTA EQU 053H ; CHANNEL 0 DATA BCTL EQU 050H ; CHANNEL 1 CONTROL ;<--- Adjust as necessary, BDTA EQU 052H ; CHANNEL 1 DATA PortA_8255 EQU 058H ;A port of 8255 ;<--- Adjust as necessary PortB_8255 EQU 059H ;B port of 8255 PortC_8255 EQU 05AH ;C Port of 8255 PortCtrl_8255 EQU 05BH ;8255 configuration port C AinBout8255cfg EQU 10011000b ;88H, Set 8255 ports:- A input, B output, ;C(bits 0-3) output, (bits 4-7)input AoutBin8255cfg EQU 10001010b ;85H, Set 8255 ports:- A output, B input, ; ;C(bits 0-3) output, (bits 4-7)input) ; ; ;<<<< Propeller Video board will be used for Consol I/O <---- Adjust if different ; CONSOL_IN EQU 01H ;Note need to strip 8th (parity) bit CONSOL_OUT EQU 01H CONSOL_STAT EQU 00H CHAR_IN_OK EQU 02H ;02H if there is a character at consol keyboard CHAR_OUT_OK EQU 04H ;Mask for CRT output MONITOR EQU 0F000h ;location of Z80 monitor ;---------------------------------------------------------------------------------- ORG 100H ;Program must be loaded at 100H START: LD SP,STACK DI ;No interrupts XOR A ;SET INTERUPT TO PAGE 0H LD I,A ;Z80 Interrupt page 0 LD A,0 LD (INIT_FLAG),A ;UARTS not initilized START_MENU: LD DE,SIGNON ;Signon/main menu CALL PRINT_STRING LD DE,MAIN_MENU ;Load Menu CALL PRINT_STRING ; STARO: CALL TI ;Main loop. Monitor will stay here until cmd. AND 7FH JR Z,STARO CP 'A' JP Z,INITSCC ;"Initilize the Zilog UART CP 'B' JP Z,UART_A_OUT_TEST ;Send continous 3's to UART Port A at 19,200 Baud CP 'C' JP Z,UART_A_IN_TEST ;input and display at 19,200 Baud CP 'D' JP Z,TEST_8255_PORT_A JP ERROR ;Not a valid menu selection ;----------------------------------------------------------------------------- INITSCC: CALL INIT$SCC ;Initilize the Zilog 8530-0 & 1 ports LD DE,INIT_ZILOG ;Have initilize Zilog UART CALL PRINT_STRING LD DE,INIT_ZILOG ;Have initilize Zilog UART CALL USB_STRING ;Send to USB terminal as well LD A,0FFH LD (INIT_FLAG),A ;Flag UARTs as initilized JP START_MENU ;----------------------------------------------------------------------------- UART_A_OUT_TEST: ;UART 0 LD A,(INIT_FLAG) OR A JR Z,UART_NOT_INIT LD DE,UART_A_OUT_MSG ;UART 0 outputting 3,3,3,3...test. Hit an key to abort CALL PRINT_STRING UART_A_OUT1_TEST1: LD C,33H ;Will send 3,3,3,3... CALL SERIAL_A_OUT CALL ZCSTS ;Any character aborts test JP Z,UART_A_OUT1_TEST ABORT_SERIAL: CALL ZCI ;Clear bbuffer JP START_MENU UART_NOT_INIT: LD DE,UART_INIT_MSG ;'Zilog 8530 SCC chip UARTs not initilized!',CR.LF,0 CALL PRINT_STRING JP START_MENU ;----------------------------------------------------------------------------- UART_A_IN_TEST: LD A,(INIT_FLAG) ;UART 0 OR A JR Z,UART_NOT_INIT LD DE,UART_A_IN_MSG ;'Type data on USB terminal. Should appear here (& on the USB terminal) CALL PRINT_STRING LD DE,UART_A_IN_MSG ;Type data on USB terminal. Should appear here (& on the USB terminal) CALL USB_STRING UART_A_IN_TEST1: CALL SERIAL_A_IN ;Get the character from the in UART port 0 LD C,A CP ESC JP Z,DONE_IN_TEST PUSH BC CALL ZCO POP BC ;Send to console CALL SERIAL_A_OUT ;also echo on terminal JP UART_A_IN_TEST1 ;Continue until abort DONE_IN_TEST: LD A,0 ;Don't want to return with ESC JP START_MENU ;----------------------------------------------------------------------------- TEST_8255_PORT_A: ;85H, Set 8255 ports:- A output, B input, LD DE,CHECK_PORTA_MSG ;Check port a bits flip 0,1,0,1... CALL PRINT_STRING LD A,AoutBin8255cfg ;C(bits 0-3) output, (bits 4-7)input OUT (PortCtrl_8255),A ;Config 8255 chip, Mode 0 PORT_A_LOOP: LD A,0FFH OUT (PortA_8255),A CALL DELAY ;Delay to see bits flipping with probe LD A,00H OUT (PortA_8255),A CALL ZCSTS ;Any character aborts test JP Z,PORT_A_LOOP CALL ZCI ;Clear bbuffer JP START_MENU ;-------------------- Support Routines ------------------------ ; ;KEYBOARD HANDELING ROUTINE (WILL NOT ECHO CR/LF) ;IT CONVERTS LOWER CASE TO UPPER CASE FOR LOOKUP COMMANDS ;ALSO ^C WILL FORCE A JUMP TO MONITOR at 0F000H ;ALL OTHERE CHARACTERS ARE ECHOED ON CONSOL TI: CALL ZCI CP CR RET Z CP ESC ;ESC BACK to Monitor JP Z,TO_MONITOR PUSH BC LD C,A CALL ZCO LD A,C POP BC CP 40H ;LC->UC RET C CP 7BH RET NC AND 5FH RET TO_MONITOR: LD HL,0F000H ;Location of Z80 monitor JP (HL) PRINT_STRING: ;A ROUTINE TO PRINT OUT A STRING @ [DE] LD A,(DE) ;UP TO THE FIRST '$'. INC DE OR A RET Z CP '$' RET Z LD C,A CALL ZCO ;Console Out JR PRINT_STRING USB_STRING: ;A ROUTINE TO SEND TO USB TERMINAL OUT A STRING @ [DE] LD A,(DE) ;UP TO THE FIRST '$'. INC DE OR A RET Z CP '$' RET Z LD C,A CALL SERIAL_A_OUT ;USB Out JR USB_STRING ; Print an 8 bit number, located in [A] HEXOUT: PUSH AF ;No registers altered PUSH BC PUSH AF RRCA RRCA RRCA RRCA CALL ZCONV POP AF CALL ZCONV POP BC POP AF RET ZCONV: AND A,0FH ;HEX to ASCII and print it ADD A,90H DAA ADC 40H DAA LD C,A CALL ZCO RET ZCO: IN A,(CONSOL_STAT) ;SD SYSTEMS OR PROPELLER CONSOLE I/O BOARD PORT CONSOLE OUT AND CHAR_OUT_OK JR Z,ZCO LD A,C OUT (CONSOL_OUT),A RET ;RETURN CHARACTER SENT IN [A] ZCSTS: IN A,(CONSOL_STAT) AND CHAR_IN_OK JP Z,NOCHAR XOR A DEC A ;RETURN WITH 0FFH IN [A] IF SOMETHING RET NOCHAR: XOR A ;RETURN WITH 0 IN A IF NOTHING THERE RET ZCI: IN A,(CONSOL_STAT) ;NEED CONSTAT TO CLEAN UP SHIFT KEYS ETC AND CHAR_IN_OK JR Z,ZCI IN A,(CONSOL_IN) AND 7FH ;7 bits only RET DELAY: LD A,80H ;DELAY to see bits flipping DELAY1: LD B,0 M0: DJNZ M0 DEC A JR NZ,DELAY1 RET SERIAL_A_OUT: ;Send a single character out via UART Port A XOR A,A ;Will try 256 times, then timeout MODXXX: PUSH AF IN A,(ACTL) ;MODEM/SERIAL OUT AND 04H ;Are we ready for a character JR NZ,SENDM ;NZ if ready to recieve character POP AF DEC A JR NZ,MODXXX JP SERIAL_A_TIMEOUT SENDM: POP AF LD A,C OUT (ADTA),A ;Send it RET SERIAL_A_TIMEOUT: LD DE,TIMEOUT_SERIAL_A CALL PRINT_STRING RET SERIAL_A_IN: ;Get a single character from UART Port A XOR A ;Will try 256 times, then timeout SERIAL$INX: PUSH AF CALL SERIAL$STAT ;MODEN/SERIAL IN JP NZ,GETMOD POP AF DEC A JP NZ,SERIAL$INX RET GETMOD: POP AF IN A,(ADTA) RET SERIAL$STAT: ;Get Serial A Input port Status IN A,(ACTL) AND A,01H RET Z ;Ret NZ if nothing XOR A DEC A RET ;Ret FF/NZ if something ;S100Computers Serial I/O Board Initilization ;Note Zilog SCC serial port B will be set to 19,200 Baud initially ;Note Zilog SCC serial port A will be set to 19,200 Baud initially INIT$SCC: LD A,ACTL ;Program Channel A of UART 0 LD C,A LD B,0EH ;Byte count LD HL,SCCINIT$A$A MORE1: LD A,(HL) OUT (ACTL),A INC HL DJNZ MORE1 INIT$SCC$B: LD A,BCTL ;Program Channel B of UART 1 LD C,A LD B,0EH ;Byte count LD HL,SCCINIT$A$B MORE2: LD A,(HL) OUT (ACTL),A INC HL DJNZ MORE2 RET ; ; SCCINIT$A$A: DB 04H ;Point to WR4 >>>>>>>>>>>>>>>>>>>>> (RS232 UART) DB 44H ;X16 clock,1 Stop,NP ; DB 04H ;X1 clock,1 Stop,NP DB 03H ;Point to WR3 DB 0C1H ;Enable reciever, Auto Enable, Recieve 8 bits ; DB 0E1H ;Enable reciever, No Auto Enable, Recieve 8 bits (for CTS bit) DB 05H ;Point to WR5 DB 0EAH ;Enable, Transmit 8 bits DB 0BH ;Set RTS,DTR, Enable. Point to WR11 DB 56H ;Recieve/transmit clock = BRG DB 0CH ;Point to WR12 ; DB 40H ;Low Byte 2400 Baud ; DB 1EH ;Low Byte 4800 Baud ; DB 0EH ;Low Byte 9600 Baud DB 06H ;Low byte 19,200 Baud ; DB 02H ;Low byte 38,400 Baud ; DB 13H ;low byte 115,200 Baud (With 1X clk) ; DB 00H ;Low byte 76,800 Baud ; DB 06H ;Try for 460800 DB 0DH ;Point to WR13 DB 00H ;High byte for Baud DB 0EH ;Point to WR14 DB 01H ;Use 4.9152 MHz Clock. Note SD Systems uses a 2.4576 MHz clock, enable BRG DB 0FH ;Point to WR15 DB 00H ;Generate Int with CTS going high SCCINIT$A$B: DB 04H ;Point to WR4 >>>>>>>>>>>>>>>>>>>>>>>>> (Speech) DB 44H ;X16 clock,1 Stop,NP DB 03H ;Point to WR3 DB 0C1H ;Enable reciever, Auto Enable, Recieve 8 bits DB 05H ;Point to WR5 DB 0EAH ;Enable, Transmit 8 bits DB 0BH ;Set RTS,DTR, Enable. Point to WR11 DB 56H ;Recieve/transmit clock = BRG DB 0CH ;Point to WR12 DB 06H ;Low byte 19,200 Baud <<<<<<<<<<< Note Speech synthizer defaults to this value DB 0DH ;Point to WR13 DB 00H ;High byte for Baud DB 0EH ;Point to WR14 DB 01H ;Use 4.9152 MHz Clock. Note SD Systems uses a 2.4576 MHz clock, enable BRG DB 0FH ;Point to WR15 DB 00H ;Generate Int with CTS going high ; ; ERROR: LD DE,MENU_ERROR_MSG CALL PRINT_STRING JP START_MENU ;-------------------------------------------------------------------------------------------------------- SIGNON: DB CR,LF,LF DB '--------- 3P+2S IO test Program Menu (V0.1 10/9/2023)--------',CR,LF,LF,0 MAIN_MENU: DB 'A Initilize the Zilog 8530 SCC chip UART. 19,200 Baud, N-8-1',CR,LF DB 'B Send a continious 33H to UART Port 0',CR,LF DB 'C Read data from the USB Port 0 terminal.',CR,LF DB 'D Initilize the 8255A Chip (Port A out, Port B in)',CR,LF DB 'ESC Return to Monitor at F000H',CR,LF,LF DB 'Menu choice ---->$',0 MENU_ERROR_MSG DB BELL,CR,LF,'Invalid Menu Character',CR,LF,0 INIT_ZILOG DB CR,LF,'Zilog SCC Ports 0 & 1 initilized to 8 Bits, 1 Stop bit, NP, RTS on, 19,200 Baud.',CR,LF,LF,0 CHECK_PORTA_MSG DB CR,LF,'8255 Port A is now in output mode. Hit any key to abort.',CR,LF,LF,0 UART_A_OUT_MSG DB CR,LF,'UART 0 outputting 3,3,3,3...test. Hit an key to abort.',CR,LF,0 TIMEOUT_SERIAL_A DB CR,LF,BELL,'UART 0 port not ready!',CR,LF,0 UART_A_IN_MSG DB CR,LF,'Type data on USB terminal. Should appear here (& on the USB terminal).' DB CR,LF,'ESC to abort.',CR,LF,0 UART_A_LOOP_MSG DB CR,LF,'UART 0 outputting 3,3,3,.... and inputting sent data . Hit an key to abort.',CR,LF,0 UART_INIT_MSG DB CR,LF,BELL,'Zilog 8530 SCC chip UARTs not initilized!',CR,LF,0 INIT_FLAG DB 0H DS 40H STACK: DB 0H SSC_Init_Flag: DB 0FFH ; ; END