**** prou-ad1.023 **** Thió  ió  thå reviseä version¬  receiveä earlù  Januarù '86. BIOº  Greç  Havengá ió á recenô graduatå froí  Michigaî Technologicaì University¬ anä holdó á bachelor'ó degreå iî  Computeò  Science®   Hå  liveó  iî  Granä   Rapids¬ Michigan¬  anä  ió aî associatå oæ Meijers¬  Inc®  Wheî he'ó noô gettinç á greeî taî froí á terminal¬ hå enjoyó restoring classic cars, cooking, and playing guitar. Programming the 8251A USART Chip by Gregory A. Havenga [Now¬  whù woulä yoõ eveò wanô tï prograí thå USARÔ oæ youò  Morrow¿  Iæ  yoõ  eveò havå reasoî  tï  calì  á mainframå (large¬ central© computer¬ youò simplå modeí prograí  jusô  won'ô do®  Mosô modeí programó  assumå thaô  you'lì  bå  communicatinç  witè  micrï  bulletiî boardó  whicè  requirå  "8-bit¬   onå  stoð  bit¬   nï parity"--aî agreemenô oî ho÷ tï geô byteó  across®  Á mainframå maù requirå somethinç likå "7-bit¬ twï stoð bits¬  odä parity.¢ You'ä neeä tï geô á modeí prograí thaô  wilì givå yoõ thå necessarù optionó foò  change¬ or“  handlå  thå  probleí yourselæ bù doinç  whaô  thió articlå wilì teacè you® --Ed.] Thió articlå shoulä helð thoså useró whï wisè  tï kno÷  á  littlå  morå abouô thå internaì  workingó  oæ theiò Morrows®  Becauså iô ió writteî foò thå generaì user¬  noô  jusô uó technoids¬  morå thaî á fe÷  termó havå tï bå defined®  Thió haó thå wondrouó effecô  oæ takinç uð mucè space¡ Thå firsô sectioî wilì describå whaô  thå 8251Á USARÔ chið ió anä definå thå termó onå needó tï kno÷ iî ordeò tï uså it®  Thå seconä sectioî actuallù  getó  dowî  tï brasó  tackó  bù  introducinç programminç examples. Parô 1º EXPLORINÇ THÅ 8251Á USART Essentially¬  thå  8251Á ió á chið thaô  convertó "paralleì data¢ froí youò computer'ó microprocessoò tï "seriaì data¢ anä vicå versa® Thå letteró USARÔ stanä forº         Universaì        Synchronous/Asynchronouó Receiver/Transmitter®  Thå 8251Á chið ió useä iî  thå MD1¬  MD2¬  anä MD3» iî harddisë MD's¬ differenô chipó arå used® Beforå wå caî actuallù geô tï thå subjecô oæ programminç  thå chip¬  wå neeä tï understanä whaô  iô does¬  anä whù iô doeó it®  Also¬ wå neeä tï definå á fe÷  terms¬   thå  mosô  importanô  beinç  seriaì  anä Šparalleì formó oæ datá transmission. Parallel and Serial Data Transmission Iî  paralleì transmission¬  eacè bytå oæ datá  ió transmitteä  alì  eighô bitó aô  once¬  througè  eighô separatå wires¬ whilå iî seriaì transmission¬ thå datá ió senô ouô througè onå wire¬  onå biô aô á time®  Iæ youò computeò haó á Centronicó porô ouô thå bacë oæ iô (usuallù  useä foò youò printer)¬  yoõ wilì noticå (iî mosô cases© thaô thå cablå connectinç thå computeò anä thå  printeò ió flaô anä wide®  Thió ió  becauså  thå transmissioî formaô ió paralleì anä thereforå requireó (aô least© eighô wireó tï carrù eacè bytå oæ datá froí thå computeò tï thå printer® (There'ó á loô morå thaî eighô  wireó iî thaô cable¬  buô á discussioî oæ  whaô thå otheò oneó arå ió á gooä topiã foò anotheò articlå Anyonå ouô therå carå tï takå á staâ aô it?). Manù  computeró  uså paralleì  datá  transmissioî internally¬ anä seriaì datá transmissioî wheî theù arå sendinç  tï  oò  receivinç  froí  externaì  equipment® That'ó  wherå thå 8251Á comeó in®  Iô functionó aó  á kinä  oæ  "switchbox¢ iî convertinç seriaì  datá  intï paralleì  datá foò youò computeò anä vicå versa®  Seå thå illustratioî belo÷ foò á typicaì uså oæ USARTs. Practical Uses of Parallel and Serial Modes Whù uså paralleì oveò seriaì datá transmissioî oò vicå versa¿  Á fe÷ importanô reasonó (therå arå more© arå 1© speed»  2© thå distancå thaô thå signaló caî bå transmitteä    reliablù   withouô   needinç    outsidå amplification»  anä  3© simplificatioî oæ  thå  cableó needeä tï connecô computeró tï deviceó likå modemó anä printers. Aó  foò speed¬  paralleì ió generallù fasteò thaî seriaì  datá  transmission®  Thå reasoî foò  thaô  ió simple®  Thinë  oæ paralleì transmissioî  aó  beinç likå á largå supermarkeô checkout® Manù peoplå caî gï ouô  througè  separatå  laneó alì aô  thå  samå  time® Thinë  oæ  seriaì transmissioî likå á grouð oæ  peoplå standinç  iî  linå alì waitinç theiò  owî  turn®  Thå purposå oæ thå USARÔ ió tï converô á strinç oæ  seriaì bitó  intï  á grouð oæ paralleì transmitteä  bitó  anä vicå versa. Thå   distancå  thaô  datá  caî  bå   transmitteä reliablù  thougè á regulaò non-amplifieä cablå dependó upoî  thå  strengtè  oæ  thå  voltageó  used®   Seriaì transmissionó arå strongeò thaî paralleì becauså  theù arå designeä tï coveò lonç distances¬ whereaó paralleì signals¬  designeä tï bå useä withiî thå computer¬ arå comparativelù weak®  Sï wheî yoõ uså paralleì signaló Štï transmiô oveò lonç cables¬  yoõ maù havå á problem® Thå  signaló  caî  looså mucè oæ  theiò  strengtè  anä becomå  susceptiblå tï thå introductioî oæ noiså  intï thå transmission. Thå  cableó useä tï transmiô seriaì datá  usuallù neeä  onlù  threå wiresº  onå tï transmiô datá iî  onå direction¬  onå  tï  transmiô  datá  iî  thå  oppositå direction¬  anä onå foò "handshaking.¢ Iî á  paralleì cable¬  therå  havå tï bå aô leasô eighô wireó foò onå waù transmission®  Sï foò twï waù datá  transmission¬ wå neeä aô leasô eighô morå wires¬  pluó alì thå wireó necessarù foò handshaking¬ etc® Thió ió whù thå cablå ió  sï widå anä flat®  Besideó that¬  ribboî cablå ió morå  expensivå thaî mosô cablå useä foò  seriaì  datá transmission. Ho÷  doeó  alì  thió relatå tï ouò  lowlù  littlå USARÔ  oî boarä thå Morrow¿  Well¬  thå sweeô  littlå 8251Á  chið  caî  handlå almosô  anù  forí  oæ  seriaì transmissioî  oæ  data--becauså  iô  ió  programmable¡ Now¬  É  kno÷ therå arå á fe÷ grumbleó ouô therå  froí peoplå  whï  seå  nothinç buô hassleó witè  havinç  tï prograí  somethinç elså (afteò all¬  jusô  programminç thå computeò itselæ ió difficulô enough!)® Buô really¬ thió thinç ió á snap¡ However¬  readinç Intel'ó documentatioî oî iô  ió nï fun¡  É spenô threå dayó tryinç tï understanä whaô theù  werå talkinç about¡  Thå chið ió designeä tï bå verù  flexible¬   buô  mù  experiencå  haó  beeî  thaô flexibilitù  breedó confusion¡  Giveî  teî  differenô wayó  tï  dï  something¬  teî  differenô  peoplå  wilì implemenô thå solutioî iî teî differenô ways¡  Iî ouò case¬  Mr®  Morro÷ anä cre÷ havå simplifieä thingó foò us¬   anä   wå   wilì  concerî  ourselveó   witè   thå implementatioî  useä  foò  thå Morro÷  Micrï  Decisioî only. Accessing The 8251 USART Ho÷  doeó thå microprocessoò iî youò Morro÷  talë tï thå chip¿ Iô doeó iô bù meanó oæ "porô addresses.¢ Wheî iô wantó tï senä oò receivå á bytå tï oò froí thå USARÔ chið associateä witè thå printer/modeí connectoò oæ á floppy-systeí Morrow¬  iô useó thå porô addresseó 25´  anä 255--$FÅ anä $FÆ iî hex®  Usinç  theså  porô addresseó iî conjunctioî witè thå USARÔ ió thå waù foò thå  microprocessoò  tï  geô througè  tï  thå  outsidå world. Porô  locatioî  25µ ió whaô ió termeä  thå  USARÔ Command/Statuó port®  Wå caî checë thå currenô statuó oæ  thå porô bù readinç thå valuå aô thå port¬  oò seô iô bù sendinç á valuå tï thå port. Š Porô locatioî 25´ ió thå USARÔ Input/Outpuô port® Thió  ió  wherå informatioî ió actuallù  senô  tï  anä receiveä froí thå USART. Accessinç theså portó ió donå iî á numbeò oæ wayó dependinç upoî whaô languagå ió used® Iî Assembly¬ (É know¬  "yuck¡  Assemblù  language!¢  saù alì yoõ  non- hackeró  ouô there!)¬  therå arå twï commandó useä  tï communicatå  witè  ports--OUÔ anä IN®  Aó  yoõ  mighô guess¬  OUÔ sendó somethinç ouô througè thå port¬  anä IÎ receiveó somethinç iî througè thå port®  Iî  Turbï Pascal¬  yoõ havå á porô array®  (Blesó Phillipå Kahî foò thió littlå gem¡ Iæ yoõ don'ô alreadù havå it¬ geô it¡  É  don'ô uså BASIÃ anymore!© Tï senä  somethinç ouô tï thå port¬ merelù makå aî assignmenô tï thå porô array®  Tï  receivå  somethinç  froí  thå  port¬  seô somethinç equaì tï thå port® Herå ió aî example: port[255] := ready_for_transmission; û Thió putó á numeriã valuå storeä iî thå variablå "ready_for_transmission¢ ouô tï thå porô } while ( port[255] and 4 ) <> 4 do û waiô foò porô tï havå thå biô thirä froí thå right to be set to one } Otheò  languageó  shoulä  havå  similaò  commands®  Iî MBASIÃ anä Nevadá FORTRAN¬  foò example¬  thå commandó arå  INÐ anä OUT¬  witè INÐ beinç á functioî returninç thå valuå aô thå port¬  anä OUÔ beinç á subroutinå (oò statemenô iî BASIÃ terminology© thaô setó thå porô  tï á  particulaò  value®  É wilì uså Pascaì  terminologù froí no÷ oî becauså iô ió thå closesô tï plaiî Englisè anä  ió  easù tï converô tï  otheò  languages®  (Also¬ Pascaì allowó må tï sho÷ structureä exampleó whicè  ió importanô tï me¬ beinç á computeò sciencå major!© Communicating with the 8251A Oî tï thå beeæ oæ thå subject® Thå procedurå foò communicatinç witè thå chið ió outlineä below. 1® We geô thå chip'ó attentioî, lettinç iô kno÷ we want to program it. 2® We assemble aî instructioî worä containinç thå bitó seô thaô wilì seô thå chið uð tï transmit in the manner we want it to. 3® We check anä set thå portó tï thå chip. Let'ó   begiî  bù  tryinç  tï  geô  thå   USART'ó attentioî  bù  resettinç it®  Thió ió accomplisheä  bù sendinç thå thå USARÔ Command/Statuó porô (255©  threå Šzeros¬ followeä bù onå $4° hex® Here'ó aî example: port[255Ý :½ $00» û Telló porô thaô we'rå } port[255] := $00; { getting ready to reset it } port[255Ý :½ $00» port[255] := $40; { Internal Reset Command } Important Terms No÷ thaô thå chið haó ouò attention¬  we'rå readù tï  telì  iô  whaô tï do®  Thå waù wå dï thió  ió  bù settinç thå bitó iî á bytå registeò iî thå USARÔ  thaô correspondó  witè  thå waù wå wanô tï  transmiô  data® Therå  arå á fe÷ termó tï becomå familiaò witè herå sï wå wilì kno÷ whaô wå arå actuallù tellinç thå chið  tï do® Herå arå thå terms: Bauä Rate“--Thå speeä aô whicè wå transmiô data®        Aô 30° baud¬ wå transmiô abouô 3° characteró peò        second.      Characteò Length--Thå lengtè oæ thå datá        (iî bits© thaô wå wanô tï transmit® Iî        mosô applications¬ thió wilì bå · oò ¸ bits¬        dependinç oî thå receivinç device'ó        requirements® Foò communicationó prograí        applications¬ thió wilì bå whateveò thå hosô        computeò requires® Mù experiencå haó beeî thaô        thå Sperrù mainframå thaô É havå accesó tï        requireó · datá bits¬ whilå mosô bulletiî boardó        requirå ¸ datá bitó peò character.      Parity--Á forí oæ erroò checking® Sometimes¬ iî        thå courså oæ transmission¬ á biô oò twï (oò        more¬ iæ thå transmissioî ió reallù bad!© maù        geô switcheä froí beinç á ± tï á 0¬ oò vice-        versa® Paritù checkinç ió donå bù addinç uð alì        thå bitó withiî eacè transmitteä bytå aó iæ theù        werå littlå numbers® Now¬ supposå thaô wå arå        usinç eveî paritù (therå ió even¬ odä anä nï        parity)® Iæ alì thå bitó adä uð tï aî eveî        number¬ theî thå paritù biô ió seô tï 0® Iæ thå        bitó adä uð tï aî odä number¬ thå biô ió seô tï        1¬ makinç thå totaì aî eveî number® Iî odä        parity¬ aó yoõ mighô guess¬ thå oppositå        occurs--thå paritù biô ió seô tï makå thå totaì        oæ alì thå bitó withiî thå bytå aî odä number®        Usinç nï parity¬ thå paritù biô ió stilì therå        buô ió merelù ignored® (Thå paritù biô ió addeä        to the left side.) Herå arå somå examples: 1. Eighô datá bits¬ Eveî paritù:         10010100 - parity bit set to 1 Š This is what gets sent: 100101001 2. Seven data bits, Odd parity:         1110100 - parity bit set to 1 This is what gets sent:         11101001     Stoð Bits--Á biô oæ informatioî senô alonç foò        synchronizatioî purposes® Iæ yoõ looë aô thå        completå signaì thaô ió useä tï transmiô onå        completå bytå oæ information¬ yoõ wilì noticå        thaô therå arå twï morå bitó addeä tï datá anä        paritù bits® Theså arå thå starô biô anä thå        stoð bit® Theiò functioî ió tï ensurå thaô thå        receivinç enä knowó whicè oæ thå ¸ datá bitó ió        which® Thaô ió calleä synchronization® Thå        wholå traiî oæ bitó seriallù transmitteä startó        witè á starô bit¬ followeä bù · oò ¸ datá bits¬        followeä bù á paritù bit¬ followeä bù á stoð        bit® Iô lookó likå this:        --------------------------------------------         ILLUSTRATION        --------------------------------------------        Thå starô biô ió alwayó "1¢ anä thå stoð biô ió        alwayó "0¢. Thaô ió á cluå tï thå circuitrù        iî á USARÔ wherå thå (variable© datá anä paritù        bitó begiî anä end® Alì thå bitó arå equallù        lonç iî timå wheî transmitteä aó "uð anä down¢        electricaì signals¬ excepô thå stoð bit¡ Iô ió        thå onlù biô thaô caî havå á lengtè equaì tï 1.°        timeó oò 1.µ timeó oò 2.° timeó thå lengtè oæ        eacè oæ thå otheò bits® Thå settinç oæ thå        lengtè oæ thå stoð biô agaiî dependó oî thå        requirementó oæ thå remotå equipmenô yoõ wanô tï        communicatå with. Necessary Description Conventions Thå  chip'ó  datá transmission/receptioî modå  ió programmeä  bù sendinç á worä containinç thå bitó  seô tï controì baud-ratå factor¬  characteò length¬ paritù characteristics¬ anä numbeò oæ stoð bits® Wå musô no÷ establisè  á conventioî foò naminç thå bitó iî á  bytå iî ordeò tï avoiä (create?© confusion®  Wå wilì refeò Štï thå lefô mosô biô oæ aî eighô biô bytå aó beinç thå seventè bit¬  anä aó thå highesô biô oæ thå byte® Thå right-mosô biô wilì bå referreä tï aó thå  zeroth¬  oò lowesô   bit®   Thió  notatioî  ió  useä  becauså  iô representó   exactlù   whaô   eacè   biô    representó numerically® Thå lowesô biô representó 2^0¬ oò twï tï thå zerotè power® Bù  mathematicaì  convention¬  anù numbeò tï  thå zerotè poweò ió 1® Thå firsô biô representó 2^± (twï tï   thå  firsô  power)®   Again¬   bù   mathematicaì convention¬  anù  numbeò tï thå firsô power¬  ió  jusô thaô number¬  iî ouò case¬  2^± equaló 2® Thå seventè biô  representó 2^· (twï tï thå seventè poweò ©  whicè ió 12¸ tï uó peoplå witè 1° fingeró anä 1° toes® Thió 2^¿ notatioî ió ho÷ ouò computeò countó aó eacè biô ió eitheò á ± oò á zero® Thinë oæ thå computeò aó havinç onlù   onå  finger--oò  thumâ  iæ  youò  computeò   ió particularlù clumsy¡ (Checë ouô á booë describinç ho÷ computeró  arå  seô uð anä ho÷ theù worë  iæ  yoõ  arå interesteä  iî  ho÷  binarù arithmetiã  ió  performed® It'ó  kinä oæ interestinç tï kno÷ jusô ho÷  dumâ  youò computeò  is®  Iô  putó yoõ anä youò computeò iî  thå propeò perspective--YOÕ arå thå boss!) Command Instructions Ok now, what bits mean what? Consider our command instruction (one byte). *-------------------------------* | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | *-------------------------------* Bitó  ·  anä  ¶ controì thå numbeò  oæ  stoð  bits® (We'lì geô tï thå bitó markeä "X¢ aó wå gï along.) *-------------------------------* | 0 | 1 | X | X | X | X | X | X | *-------------------------------* 1 Stop bit *-------------------------------* | 1 | 0 | X | X | X | X | X | X | *-------------------------------* 1.5 Stop bits *-------------------------------* | 1 | 1 | X | X | X | X | X | X | *-------------------------------* 2 Stop bits Bit 5 Sets either Even or Odd parity. Š *-------------------------------* | X | X | 0 | X | X | X | X | X | *-------------------------------* Odd Parity *-------------------------------* | X | X | 1 | X | X | X | X | X | *-------------------------------* Even Parity Biô ´ Enableó parity® Foò eveî oò odä parity¬ this bit must be set to one. For none, zero. *-------------------------------* | X | X | X | 0 | X | X | X | X | *-------------------------------* No Parity *-------------------------------* | X | X | X | 1 | X | X | X | X | *-------------------------------* Parity Bits 3 and 2 control character length. *-------------------------------* | X | X | X | X | 0 | 0 | X | X | *-------------------------------* Character Length 5 bits *-------------------------------* | X | X | X | X | 0 | 1 | X | X | *-------------------------------* Character Length 6 bits *-------------------------------* | X | X | X | X | 1 | 0 | X | X | *-------------------------------* Character Length 7 bits *-------------------------------* | X | X | X | X | 1 | 1 | X | X | *-------------------------------* Character Length 8 bits Bits 1 and 0 control the baud rate factor. *-------------------------------* | X | X | X | X | X | X | 0 | 0 | *-------------------------------* Synchronouó Modå foò IBÍ - typå data formats Š *-------------------------------* | X | X | X | X | X | X | 0 | 1 | *-------------------------------* Clock rate * 1 *-------------------------------* | X | X | X | X | X | X | 1 | 0 | *-------------------------------* Clock rate * 16 .pa Š *-------------------------------* | X | X | X | X | X | X | 1 | 1 | *-------------------------------* Clock rate * 64 Foò thå Morro÷ MD3¬  Rev® 2¬ thå bauä ratå factoò shoulä bå seô tï thå Clocë ratå ª 1¶ setting® Settinç thå  bauä  ratå  shoulä bå donå  witè  thå  bauä  ratå generator® Thå documentatioî oæ ho÷ tï dï thió caî bå founä  iî  twï differenô placeó thaô É kno÷  of®  Thå firsô  ió  righô iî thå firsô issuå  of-- yoõ  guesseä it--MOÒ  (Vol®  1¬  #1¬  Apriì 1984¬  p®  16© iî  Davå Block'ó Ñ ¦ Á column® Thå otheò placå tï finä thió ió anotheò   Davå   Blocë   creation/publication¬   Micrï Decisioî Questionó anä Answeró (availablå froí Morrow¬ Inc.) PART 2: PROGRAMMING EXAMPLES Aô lasô wå caî looë aô somå programminç  exampleó thaô  sho÷ actuaì softwarå manipulatioî oæ thå  8251A® Thå  followinç ió writteî iî Turbï Pascal¬  buô É havå trieä  tï uså meaningfuì variablå nameó anä  hopefullù cleaò  logiã  sï  thaô iô shouldn'ô bå  toï  harä  foò someonå  tï  translatå  thió  froí  Turbï  tï  anotheò language® Yoõ caî seô uð thå chið tï transmiô datá iî thå  followinç  format®   Thå  bauä  ratå  haó   beeî specifieä bù runninç thå prograí SETUP® Thå followinç specificatioî ió foò · datá bits¬  eveî parity¬  anä ± stoð bit®  Thå modå instructioî worä shoulä looë likå thió wheî wå geô done: *-------------------------------* | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | *-------------------------------* .pa Š This is affected by the following code: program set_it_up; var baudrate, stopbits, parity, wordlength : integer; {************************************************* * * * p r o c e d u r e i n i t i a l i z e * * * *************************************************} procedure initialize_USART_mode( baudrate, stopbits, parity, wordlength : integer ); (Thå  codå  iî  thió procedurå ió parô  oæ  á  prograí copyrighteä  bù  myself¬  buô  thå  methodó  useä  arå commoî anä maù bå useä bù anyone® However¬ iô woulä bå  greatlù  appreciateä iæ crediô werå giveî  tï  thå author®  Somå codinç stylå haó beeî sacrificeä tï fiô thå MOÒ 5° columî requirement® Thanx¬ Greç Havenga) const USART_command_status = 255; var program_word : byte; { this is where we will store the Mode Instruction } begin { procedure*initialize_USART_mode } { set all bits in the instruction word to zero } program_word := 0; { set baud rate factor to Clock * 16 } program_word := 2; { Set first bit in byte to 1 } if wordlength in [ 5, 6, 7, 8 ] then begin case wordlength of Š 5º û dï nothinç - leavå botè bitó ² anä ³ at zero } ; 6: program_word := program_word or 4; { set bit 2 equal to 1 } 7: program_word := program_word or 8; { set bit 3 equal to 1 } 8: program_word := program_word or 12 { set bits 2 and 3 equal to 1 } end { case } end else begin writeln( 'Bad wordlength, 7 bits assumed ' ); program_word := program_word or 8 end; { if } if parity in [ 0, 1, 2 ] then begin case parity of 0: { none - leave bits 4 and 5 equal to 0 }; 1: { odd } program_word := program_word or 16; { Set bit 4 equal to one } 2: { even } program_word := program_word or 48 { Set bits 4 and 5 equal to one } end end else begin writeln( 'Bad Parity, even assumed ' ); program_word := program_word or 48 end; { if } if stopbits in [ 0, 1, 2 ] then begin case stopbits of 0: { 1 } program_word := program_word or 64; { Set bit 6 equal to 1 } 1: { 1.5 } program_word := program_word or 128; { Set bit 7 equal to 1 } 2: { 2 } program_word := program_word or 192 { Set bits 6 and 7 equal to 1 } Š end end else begin writeln( 'Bad Stopbit selection, 1 assumed ' ); program_word := program_word or 64 end; { if } û prograí Uarô } portÛ USART_command_status Ý :½ program_word» end; { procedure initialize_USART_mode } begin { main*program } baudrate = 300; stopbits = 1; parity = 1; wordlength = 7; initialize_USART_mode( baudrate, stopbits, parity, wordlength ); end. Well¬  thaô  concludeó thå prograí thaô describeó ho÷ tï seô thå USARÔ communicationó mode®  No÷ wå  caî movå oî tï actuallù communicatinç usinç thå USART® Wå neeä tï kno÷ ho÷ tï dï fouò things: 1® Checë thå statuó oæ thå Command/Statuó port® Thió donå bù usinç thå followinç        code or some equivalent.         variable := port[255];        Wå  caî perforí logicaì ANÄ anä OÒ operationó oî        thå bitó usinç thå followinç logic:         bit_two_set : boolean; { true/false }         .         .         .         bit_two_set := ( port[255] and 4 ) = 4;        bit_two_seô wilì havå thå valuå truå iæ biô        twï oæ thå command/statuó porô ió set¬ Š       false otherwise. 2. Seô bitó iî thå command/statuó port® Jusô        follo÷ thå samå logiã aó giveî foò settinç        bitó foò thå modå instruction® Seå prograí        above for details. 3. Receivå datá froí USARÔ I/Ï port® Thió ió        donå iî thå followinç manner® Wå wanô tï        waiô foò thå command/statuó porô tï telì uó        thaô iô haó á bytå foò us® Aô thió point¬        wå retrievå the byte from the I/O port.        û enable_for_reaä haó thå correcô bitó seô         to ready the I/O port for a read }        port[255] := enable_for_read;         { wait for data }        while (port[255] and 2) <> 2 do         port[255] := enable_for_read; { retrieve data from port number 254 }        byte_of_data := port[254]; 4. Senä   datá   ouô  thå  I/Ï   port®   Thió   ió        accomplisheä  bù logiã similaò tï #³ abovå  witè        thå followinç code.        { set value of byte to be sent }        byte_of_data := ord( 'A' );        û waiô foò porô tï bå readù foò         transmission of byte }        while (port[255] and 4) <> 4 do         { wait };        û enablå USARÔ I/Ï porô foò transmissioî oæ         bytå bù settinç thå appropriatå bitó iî         the Command/Status port }        port[255] := enable_for_write;        { send byte out port }        port[254] := byte_of_data; Interpreting the Status of the Port Belo÷ arå descriptionó oæ whaô happenó wheî á particulaò biô ió seô iî thå Command/Statuó porô bù writinç á bytå tï it. Š BIT DESCRIPTION --- -------------------------------------- · Enteò Hunô Modå - Useä foò synchronouó communication only. 6   Internaì Reset“ - Bå careful¬ thió ió whaô         wå uså foò resettinç thå chip» onlù dï         thió wheî yoõ wanô tï reseô thå chið iî         ordeò tï seô thå chip'ó communicatioî         mode. µ Requesô tï senä - Setó thå RTÓ piî oî thå chið tï zero® Useä tï controì thå RTÓ piî oæ thå seriaì porô tï zerï. Foò aî actuaì DB2µ piî number¬ consulô youò owneró manuaì, Appendiø D. ´ Erroò Reseô - Makå surå thió biô ió seô wheî yoõ wanô tï seô bitó · and/oò 2® Haó thå effecô oæ resettinç erroò flags® Morå on the error flags in the next section. 3 Senä Breaë Character“ - Seô thió biô tï         forcå thå signaì oî thå TxÄ piî oæ thå         chið low® Uså á zerï iî thió positioî foò         normaì operation. 2 Receivå Enable“ - Seô thió biô wheî yoõ         wanô tï bå ablå tï receivå á bytå froí         porô 254® Don'ô forgeô tï seô biô ´ alonç         witè thió onå oò iô won'ô work. 1 Datá Terminaì Readù - Settinç thió biô         forceó thå DTRbaò piî oæ thå chið tï zero®         Correspondó tï á piî oî thå DB2µ         connector. Seå Appendiø Ä oæ youò owner'ó         manual for an actual connector pin number. 0 Transmiô Enablå - Seô thió biô wheî yoõ         wanô tï transmiô á characteò througè porô         254. Thå followinç tablå explainó thå meaninç oæ eacè biô oæ thå bytå reaä froí thå Command/Statuó port. BIT DESCRIPTION --- -------------------------------------- 7 Datá Seô Readù - Wheî thió biô ió set¬ iô         indicateó thaô thå DSÒ piî oæ thå chið ió         aô á zerï (low© level® Thå DSÒ piî ió         connecteä tï thå DB2µ connectoò oî thå Š        back of the machine. 6 SYNDET/BRKDEÔ - Useä foò synchronouó         communication only. 5      Framinç Erroò - Thió flaç ió seô iæ á         valiä stoð biô ió noô detecteä aô thå enä         oæ everù character® Tï reseô it¬ uså thå         Erroò Reseô biô wheî sendinç thå nexô         instructioî tï thå Command/Statuó (255©         port. 4 Overruî Erroò - Thió flaç ió seô wheî thå         nexô bytå arriveó froí thå seriaì porô         beforå thå lasô onå ió reaä froí it® Iæ         yoõ geô thió one¬ youò otheò logiã ió toï         slo÷ tï keeð uð witè thå datá ratå cominç         intï thå port® Decreaså bauä rate¬ oò         optimizå youò code® Reseô witè Erroò         Reset as above. 3 Paritù Erroò - Thió flaç ió seô iæ á         paritù erroò ió detecteä aó peò thå         discussion of parity appearing above.         Reset with Error Reset as above. 2 TxÅ - Thió biô ió seô iæ thå I/Ï porô ió         freå - readù tï accepô thå nexô bytå foò         output. 1 RxRDÙ - Thió biô ió seô iæ therå ió á         byte at the I/O port ready to be read. 0 TxRDY - Thió biô ió seô iæ thå I/Ï porô ió         freå - readù tï accepô thå nexô bytå foò         output. Review Sï  let'ó  recap®  Thå procedurå foò  usinç  thå USARÔ ió aó followsº  First¬  dï á masteò reset»  geô thå   chið  readù  tï  accepô  á  communicationó  modå instructioî  - creatå  thå  instruction¬  settinç  thå appropriatå  bits®  Senä thaô tï  thå  Command/Statuó port®  Theî  checë  thå statuó oæ thå  Command/Statuó porô  tï seå iæ yoõ caî transmiô oò neeä tï receivå  á byte®  Seô thå Command/Statuó Porô tï thå appropriatå value¬   settinç  bitó  tï  allo÷  eitheò  readinç  oò writing¬  dependinç oî whicè functioî yoõ wisè tï  do® Theî  eitheò senä á bytå tï oò receivå á bytå froí thå I/Ï  port®   Continuå  tï  monitor¬   theî  seô   thå Command/Statuó  porô sendinç oò receivinç byteó  untiì yoõ arå througè usinç thå porô foò datá transfer. .pa Š That'ó  abouô  alì therå ió tï workinç  witè  thå 8251A®  Iô  reallù doeó havå somå gooä featureó (eveî thougè  É  heaò  Zilog'ó SIÏ anä PIÏ  chipó  arå  eveî nicer®  Anù  MD1± owneró ouô therå witè  somå  insidå scoop?)®  Iæ anyonå spotó anù erroró iî thió article¬ pleaså  writå  tï må sï thaô É caî makå surå thaô  thå materiaì  presenteä herå ió valiä  anä  correct®  (Iæ therå arå significanô corrections¬  É wilì submiô theí tï MOR.© É hopå thaô thió articlå caî helð yoõ becomå morå  familiaò  witè  thå internaì  workingó  oæ  youò computeò  tï  makå  iô  eveî morå  enjoyablå  tï  use® Shoulä  anù questionó ariså concerninç  thió  article¬ senä á Self-Addresseä Stampeä Envelope¬ anä É wilì trù tï answeò youò questionó aó sooî aó besô É can®  Havå á Gooä One¬ anä á gooä tomMorrow! Gregory A. Havenga 1212 Jasper Ave. Houghton, Michigan 49931 (906) 482 - 1421