[net.micro.cpm] 8251 Usart

kevinb@SDCSVAX.ARPA (12/30/85)

The CCS S-100 bus system CPU includes a small program in it's ROM for an 
auto baud rate detection for console baud rate. When you boot, you hit the
return key 3 times and you're in A> prompt. I could try to get a copy of this
to you, to use as a source for developeing a driver for whatever comm program
you're using. Yes, please send code to the below address, I'll take a look at 
it.
		
Kevin J. Belles - UUCP {sdcsvax,ihnp4!gould9,noscvax,cbosgd}!crash!kevinb

Disclaimer: Anything within, unless directly attributed is my opinion,
and does not reflect that of my place of employment. KjB

@purdue.ARPA:mjs@purdue-ecn-ee.ARPA (mjs) (12/30/85)

Thanks for your quick reply.  First of all, let me give you a little 
background about this computer(Royal Alphatronic PC).  According to Royal,
the only way to change the baud rate is by a hardwired jumper on the 
main PCB.  But, like I said, I've been able to change it as long as I
don't try to send data out. When I send something out, everything locks
up and I must do a cold boot.  This mystifies me, because everything that
I am doing seems to make sense.  Here's my setbaud.asm:


MCNTR	EQU	41H		;Modem control port
RESET	EQU	01000000B	;Value for port reset
MINIT1	EQU	01111010B	;Value for 1 stop bit, even parity,
                                ; 7 data bits, 16X baud rate
MINIT2	EQU	00010101B	;Value for Error reset, transmit 
                                ;enable, receive enable

	ORG	100H

INITIALISE:	MVI	A,RESET 	;Puts 8251 in instruction mode
		OUT	MCNTR		;
		MVI	A,MINIT1	;sets up baud, etc.
		OUT	MCNTR		;
		MVI	A,MINIT2	;Puts 8251 back in normal mode
		OUT	MCNTR
		JMP	0

This is pretty self explanatory, I guess... and it SHOULD work, but
there must be something that I'm missing... 

Let me know what you can come up with.

                                   Thanks again,
                                   Mike
                                            ihnp4!pur-ee!mjs

GRUPP@mit-mc.ARPA (Paul R. Grupp) (12/31/85)

[ I don't think the mailer will hack your return address, so here it
  goes to the list at large ]

First of all I think you want 8 data bits not 7, and the usual 1
stop bit, 16X baud clock.  Second, to RE-init the 8251 you first have
to send a command to it to turn it off, THEN the reset, init, and
enable sequence.  For 8 data, 1 stop, 16X here are the values in HEX.
0AAh 040h 0CEh 017h.  Also you *CAN* change the baud rate (within
limits) by changing the 1X, 16X, 64X clock devider rate.  i.e.
if you set the hardware switch to 1200 baud then by changing the
16X to 64X you would get 300 baud!  Hope this helps.
							--Paul

jp@lanl.ARPA (12/31/85)

It's been a while, but I recall that the 8251 had a problem with reset. 
The solutions I've seen are 1: send reset several (3?) times, 2: go through 
the reset-program sequence twice.  Don't know exactly what the problem with 
the 8251 is but that seems to fix it. 
AH, I found some code from my HAL MCEM-8080 (ca 1976).


	UARTI	EQU	8EH	;INITIAL UART MODE WORD
	URTMO	EQU	0EAH	;7 BITS, EVEN PARITY, 2 STOP
	URTCT	EQU	0BH	;UART CONTROL PORT
	URTDA	EQU	0AH	;UART DATA PORT
	UARTR	EQU	55H	;RESET COMMAND
	TXRXE	EQU	27H	;UART RX AND TX ENABLE 


INIT:	MVI	A,UARTI		;UART MODE OUT	
	OUT	URTCT 
	MVI	A,UARTR		;RESET 
	OUT	URTCT 
	MVI	A,URTMO		;FINAL UART MODE
	OUT 	URTCT
	MVI	A,TXRXE		;ENABLE UART
	OUT	URTCT
	RET


The above code works.  I have seen a slightly different way, but can't
lay my hands on it this morning.

I remember now that the 8251 comes on with its brains slightly scrambled.
There are two control bytes that are sent to the same address sequentially
and it doesn't know where it is in that sequence when first initialized.

Hope this is some help.

Jim Potter  jp@lanl.arpa

brad@DCA-EUR.ARPA (01/02/86)

It has been 8 years since I worked on the BIOS for my
NorthStar Horizon.  I just dug out the code and found that
you have to send the 8251 both a Mode Word to tell it either
Async or Sync and a Command word.  The code for my Horizon
was:
* Send Mode Word for Asynchronous Mode
*
	MVI     A,0CEH  ; 2 Stops, 16XClock, 8 Bits, No Parity
	OUT     3       ; Send to 8251 (This different from Data Port)

* Set up Control Word for 8251
*      
* RTS = Request To Send, ER = Error Reset
* RXE = Receive Enable, DTR = Data Term Ready
* TXEN = Transmit Enable
*
	MVI     A,37H   ; CMD: RTS, ER, RXE, DTR, TXEN
	OUT     3       ; Output to 8251

Hope this helps.
Brad

aep@abic.UUCP (Alex Pensky) (01/04/86)

> INITIALISE:	MVI	A,RESET 	;Puts 8251 in instruction mode
> 		OUT	MCNTR		;
> 		MVI	A,MINIT1	;sets up baud, etc.
> 		OUT	MCNTR		;
> 		MVI	A,MINIT2	;Puts 8251 back in normal mode
> 		OUT	MCNTR
> 		JMP	0
Hmm, how about that JMP 0? Does your BIOS reset the 8251 and write
"reasonable" MINIT1 and MINIT2 bytes to it on a warm boot? Mine sure
does (SANYO MBC-1000).  I use a routine just like yours but I just
return after calling it.