Intel 8251a UART initialization problem - Page 1
Forum section: electronics / projects

author: CaptDon
author_rank: Super Contributor
timestamp: May 01, 2023, 12:54:24 pm
content: I thought to post in this forum as opposed to the Vintage Computing area as there may be a wider scope of folks familiar with the I.C. According to the Intel datasheet after a hard reset we need to send a MODE word, in this case 4Eh to define 1 stop bit, 8 data bits, no parity and 16x clock divider for the baud rate. Then we must send a COMMAND word, in this case 05h to set TXRdy and RXRdy to their enabled state. Having done this the UART simply will not function and sometimes exhibits different unusual actions. Some how I found the following initialization routine to be flawless. 1st I send 82h to the Mode register (Why I can't say for sure), 2nd I send 40h (a soft reset), 3rd I send 4Eh (the mode configuration I want), 4th I sent 05h (to set TXRdy and RXRdy to their active state) and the UART performs exactly as expected. Does anyone know why I have to do these extra steps to get a correct initialization??? Only through many hours of experimentation have I found the magic sequence. Thanks for any experience, ideas or insight!!! Cheers mates!!

author: iMo
author_rank: Super Contributor
timestamp: May 01, 2023, 01:34:32 pm
content: It is ~40y back I last time messed with 8251, but as I can remember there are some differences between 8251 and 8251A, but the details got forgotten.. Thus it depends on the DS you read..

author: Andy Watson
author_rank: Super Contributor
timestamp: May 01, 2023, 02:28:48 pm
content: It's been 40 ish years since I last dabbled with these devices. All I can remmeber is that they were a bit quirky. Once somebody in the company attained the magic runes, all subsequent projects copied the initialisation code - verbatim! Does the attached note help?

author: CaptDon
author_rank: Super Contributor
timestamp: May 01, 2023, 08:22:02 pm
content: I think it eludes to a problem left unfixed by Intel as stated in the text "May come up in Command, Mode or Sync" so it is unsafe to assume it will be guaranteed to come up in the Mode state. I don't know why sending 82h as the first character and then doing a soft reset seems to be the magic solution? I have diddled with other characters but 82h is the magic bean. This was an additional communications path for an Intel SDK-85 kit. The originally supplied kit used the SID and SOD pins on the 8085 in a soft-UART style at 110 baud. I was able to get the soft-UART timings in the monitor program to run at 4800 baud with a bit of tolerable timing distortion but I am now dabbling with the 8251A 'real UART' which allows for greater and easily varied baud rates. Thanks all!! This SDK-85 has been boxed up for about 20 years and it has been fun seeing it run again!!! I have Tiny Basic and Tycon Editor Assembler running as well as the original SDK-85 monitor.

author: pqass
author_rank: Super Contributor
timestamp: May 02, 2023, 04:30:42 am
content: While researching monitor ideas for my bread-board 8085 I came across "MON85, A Software Debug Monitor For the 8085/8080" see download at bottom of page here:http://www.malinov.com/Home/sergeys-projects/minimax8085This is how it does 8251A initialization.Apparently it's "according to datasheet" to knock three times before resetting.;; Initialize the uart;; 8251A initialisation, according to datasheet (3x 00h + RESET 040h)INIT:XRA A ; Insure not setup modeOUT 9 ; Write onceOUT 9 ; Write again (now in operate mode)OUT 9 ; Write again (now in operate mode)MVI A,01000000b ; ResetOUT 9 ; write itMVI A,01001110b ; 8 data, 1 stop, x16OUT 9 ; Write itMVI A,00110111b ; RTS,DTR,Enable RX,TXOUT 9 ; Write itRET

author: eutectique
author_rank: Frequent Contributor
timestamp: May 02, 2023, 08:24:13 am
content: I have a vague recollection of performing the init sequence twice.

author: pqass
author_rank: Super Contributor
timestamp: May 02, 2023, 09:08:26 pm
content: Looking at GWMON-80 monitor here:https://github.com/glitchwrks/gwmon-80The difference between 8251 vs 8251a is that the former, following a reset, may have some garbage characters that need to be read and discarded.https://github.com/glitchwrks/gwmon-80/blob/master/i8251.inchttps://github.com/glitchwrks/gwmon-80/blob/master/i8251a.inc

author: Benta
author_rank: Super Contributor
timestamp: May 02, 2023, 10:24:25 pm
content: Quote from: pqass on May 02, 2023, 04:30:42 amThis fits 100% with the scanned page from Andy Watson. I think it's solved.

author: CaptDon
author_rank: Super Contributor
timestamp: May 03, 2023, 12:29:51 pm
content: I found that sending 82h, then 40h, then 4Eh, and finally 05h as the initialization sequence to solve all of the issues for 8N1 and 16X baud clock. Boots correctly and runs every time. As part of the troubleshooting I took the TxRdy and RxRdy pins through a 74LS04 inverter to the drive 2 LEDS each with a 470 ohm series resistor to indicate the state of the ready lines. That instantly gave an indication of what was going on. It has been a fun project to add a real UART and still maintain the soft UART formed with the SID / SOD pins on the 8085A and used by the SDK-85 monitor program. It also makes baud rate translation possible between the two styles of UART. I can input 45.45 Baudot 60WPM RTTY from my ham receiver and send it to my terminal at 4800 8N1 after character translation. I know, it's all as old as dinosaurs but it's been fun. Cheers mates, retro can be fun and educational.

author: CaptDon
author_rank: Super Contributor
timestamp: May 03, 2023, 12:32:07 pm
content: I found an error in the Intel datasheet. They listed 1.72Khz for 110 baud and a 16x clock rate. The real number should be 1.76Khz.