Author Topic: Intel 8251a UART initialization problem  (Read 2352 times)

0 Members and 1 Guest are viewing this topic.

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2614
  • Country: is
Intel 8251a UART initialization problem
« on: May 01, 2023, 12:54:24 pm »
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!!
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 6904
  • Country: li
Re: Intel 8251a UART initialization problem
« Reply #1 on: May 01, 2023, 01:34:32 pm »
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..
Readers discretion is advised..
 

Offline Andy Watson

  • Super Contributor
  • ***
  • Posts: 2340
Re: Intel 8251a UART initialization problem
« Reply #2 on: May 01, 2023, 02:28:48 pm »
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?1773296-0
 

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2614
  • Country: is
Re: Intel 8251a UART initialization problem
« Reply #3 on: May 01, 2023, 08:22:02 pm »
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.
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Offline pqass

  • Super Contributor
  • ***
  • Posts: 1168
  • Country: ca
Re: Intel 8251a UART initialization problem
« Reply #4 on: May 02, 2023, 04:30:42 am »
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/minimax8085

This 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 mode
      OUT   9             ; Write once
      OUT   9             ; Write again (now in operate mode)
      OUT   9             ; Write again (now in operate mode)
      MVI   A,01000000b   ; Reset
      OUT   9             ; write it
      MVI   A,01001110b   ; 8 data, 1 stop, x16
      OUT   9             ; Write it
      MVI   A,00110111b   ; RTS,DTR,Enable RX,TX
      OUT   9             ; Write it
      RET
 
The following users thanked this post: Ian.M

Online eutectique

  • Frequent Contributor
  • **
  • Posts: 637
  • Country: be
Re: Intel 8251a UART initialization problem
« Reply #5 on: May 02, 2023, 08:24:13 am »
I have a vague recollection of performing the init sequence twice.
 

Offline pqass

  • Super Contributor
  • ***
  • Posts: 1168
  • Country: ca
Re: Intel 8251a UART initialization problem
« Reply #6 on: May 02, 2023, 09:08:26 pm »
Looking at GWMON-80 monitor here: https://github.com/glitchwrks/gwmon-80

The 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.inc
https://github.com/glitchwrks/gwmon-80/blob/master/i8251a.inc



 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 7176
  • Country: de
Re: Intel 8251a UART initialization problem
« Reply #7 on: May 02, 2023, 10:24:25 pm »
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/minimax8085

This 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 mode
      OUT   9             ; Write once
      OUT   9             ; Write again (now in operate mode)
      OUT   9             ; Write again (now in operate mode)
      MVI   A,01000000b   ; Reset
      OUT   9             ; write it
      MVI   A,01001110b   ; 8 data, 1 stop, x16
      OUT   9             ; Write it
      MVI   A,00110111b   ; RTS,DTR,Enable RX,TX
      OUT   9             ; Write it
      RET


This fits 100% with the scanned page from Andy Watson. I think it's solved.
 

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2614
  • Country: is
Re: Intel 8251a UART initialization problem
« Reply #8 on: May 03, 2023, 12:29:51 pm »
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.
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2614
  • Country: is
Re: Intel 8251a UART initialization problem
« Reply #9 on: May 03, 2023, 12:32:07 pm »
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.
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->