LisaList2

Advanced search  

News:

2019.06.07 fixed NChat for the "Curve" theme, will eventually move it to its own page and add it to the default theme as well. Other plugins are next. see post in the Meta board for details

Pages: [1]   Go Down

Author Topic: Serial A Baud Rate correction when PFG installed but NOT using MacWorks Plus II  (Read 1307 times)

sigma7

  • Administrator
  • Full Member
  • *****
  • Karma: +22/-0
  • Offline Offline
  • Posts: 26
  • Warning: Memory errors found. Verify comments.

The PFG provides an alternate clock input to the Zilog 8530 SCC to improve compatibility with the Mac Plus when using MacWorks Plus II.

However, as stated on page 26 in the MacWorks Plus II manual, when the PFG is installed but an environment is in use that does not recognize it (currently everything other than MW+II), the modem port (Serial A) does not work correctly in that the selected baud rate does not match what actually appears at the serial port.

This issue can be mitigated when connecting to a computer that supports an arbitrary baud rate. I believe the Raspberry Pi is in this category.

The stock Lisa Serial A clock is 4.000 MHz
The Mac Plus SCC clock is 3.672 MHz (which is provided by the PFG in lieu of 4MHz)

To select a comparable baud rate that matches the actual Serial A baud rate with the PFG installed but not recognized, one could multiply the Lisa nominal baud rate by 3.672/4.

However, the 4 MHz clock in the Lisa does not divide evenly by the standard baud rates (ie. Serial A of the stock Lisa has a small baud rate error which varies with rate). Since the SCC clock rate divisors are integers, the Serial A "Actual Baud Rate" selected by the Lisa is

  ABR = 4x106 / (CM * 2 * (TC+2))

where the Time Constant TC is calculated from the desired baud rate as

  TC = Round( 4x106 / (CM * 2 * NominalBaudRate) ) -2

and CM is the internal clock mode setting for the SCC, which may be 1, 16, 32, or 64. In most cases 1 is used (if 16 is used, the ABR does not differ by much for usable baud rates).

To compensate for the PFG, multiplying the ABR by 3.672/4 gives the equivalent baud rate the other end should use for the best match.

IIRC, the PFG generates 3.672 MHz by dividing its 36 MHz oscillator by 500/51, which is exact aside from some jitter.

So, if one selects the following nominal baud rates for Serial A (using anything other than MW+II) with the PFG installed, the Actual matching baud rates would be:


Lisa           Lisa           Lisa NO PFG    Lisa +PFG
Nominal        x1 Clock Mode  Actual         Actual Matching
Baud Rate      Divisor        Baud Rate      Baud Rate
110            18180          110.00         101
150            13331          150.00         138
200            9998           200.00         184
300            6665           299.99         275
600            3331           600.06         551
1200           1665           1199.76        1101
1800           1109           1800.18        1653
2400           831            2400.96        2204
3600           554            3597.12        3302
4800           415            4796.16        4403
9600           206            9615.38        8827
19200          102            19230.77       17654
31250          62             31250.00       28688
38400          50             38461.54       35308
57600          33             57142.86       52457
115200         15             117647.06      108000
230400         7              222222.22      204000
460800         2              500000.00      459000


The resulting baud rates are not a perfect match (yet better than the stock Lisa over 1800 baud) but I expect are close enough for reliable communication.

A patch could be made to earlier MacWorks variants (and probably other environments) to fix the Serial A issue when the PFG is installed; if this would be of value to you, please let me know.

James

Note: Serial B does not have this problem as it has a 3.6864 MHz crystal which results in exact whole number divisors for common baud rates over 110.

Edits:
As posted below, the formula used initially to calculate these values was not quite correct, so this post has been updated with the hope it will be more correct.
« Last Edit: March 13, 2019, 09:47:47 pm by sigma7 »
Logged
Warning: Memory errors found. ECC non-functional. Verify comments if accuracy is important to you.

rayarachelian

  • Administrator
  • Sr. Member
  • *****
  • Karma: +11/-0
  • Offline Offline
  • Posts: 239
  • "But what's puzzling you is the nature of my game"
    • LisaEm

Even so I remember being able to get 19.2K reliably and even 56.7K most of the time on serial A, and was able to get LocalTalk working on MacWorks (non PFG) over phone-net cables. LocalTalk worked pretty well when talking to a IIcx and even some PC parallel port to phonenet localtalk adapters from coActive as well as a Ti MicroLaser.

I had a very long (25ft) null modem cable with hardware handshaking from the Lisa to a PC and it was pretty reliable, so it's not too terrible.

So tl;dr use port B for most serial things unless you need to use both localtalk and serial together.  8)
Logged
Fate whispers to the warrior, 'You can not withstand the storm.'  The warrior whispers back, 'I am the storm.'

sigma7

  • Administrator
  • Full Member
  • *****
  • Karma: +22/-0
  • Offline Offline
  • Posts: 26
  • Warning: Memory errors found. Verify comments.

Yes, Serial A is ordinarily quite usable. The baud rate error for a stock Lisa's Serial A is small, so even the worst cases should easily be handled by RS-232 like protocols.

ie. Calculated for a Stock Lisa, no PFG, Serial A

Lisa           Lisa           Lisa actual   
Nominal        x1 Clock Mode  Serial A       
Baud Rate      Divisor        Baud Rate       Error
110            18180          110.00         -0.001%
150            13331          150.00          0.003%
200            9998           200.00          0.000%
300            6665           299.99         -0.005%
600            3331           600.06          0.010%
1200           1665           1199.76        -0.020%
1800           1109           1800.18         0.010%
2400           831            2400.96         0.040%
3600           554            3597.12        -0.080%
4800           415            4796.16        -0.080%
9600           206            9615.38         0.160%
19200          102            19230.77        0.160%
31250          62             31250.00        0.000%
38400          50             38461.54        0.160%
57600          33             57142.86       -0.794%
115200         15             117647.06       2.124%
230400         7              222222.22      -3.549%
460800         2              500000.00       8.507%


However, if the PFG is installed (and not using MW+II), the error becomes > 9% and with 8 bits + 1 start and 1+ stop and maybe parity bits, that error is around 1 bit per character, resulting in a probably unusable failure rate. Hence the list in the first post of "actual" baud rates to select in that circumstance to avoid having to remove the PFG.

Edit:
An advantage to using Serial A in MacWorks variants is that the port is polled while some interrupts are disabled to prevent the loss of incoming characters. Serial B doesn't have this feature and so there is a greater chance of missing data. I recall this difference being quite evident when downloading a file to a floppy disk. I don't know how the other environments' treatment of the serial ports differs.

More Edits:
As posted below, the formula used initially to calculate these values was not quite correct, so this post has been updated with the hope it is more correct.

I see some time constants in Figure 2-10 of the 1982 Hardware Reference Manual differ by 1 from the ones I have calculated. It appears they were truncated to the next lower whole number rather than rounded to the closer whole number resulting in the higher error values in that figure. I don't know which technique is used for the time constants actually used by Lisa compatible software.
« Last Edit: March 13, 2019, 10:02:18 pm by sigma7 »
Logged
Warning: Memory errors found. ECC non-functional. Verify comments if accuracy is important to you.

rayarachelian

  • Administrator
  • Sr. Member
  • *****
  • Karma: +11/-0
  • Offline Offline
  • Posts: 239
  • "But what's puzzling you is the nature of my game"
    • LisaEm

Sure, so, what happens if you use MacWorks Plus II without the PFG installed? What breaks?
Also, if you do have the PFG installed, does it affect any other OS such as LOS/Xenix/UniPlus?
Logged
Fate whispers to the warrior, 'You can not withstand the storm.'  The warrior whispers back, 'I am the storm.'

sigma7

  • Administrator
  • Full Member
  • *****
  • Karma: +22/-0
  • Offline Offline
  • Posts: 26
  • Warning: Memory errors found. Verify comments.

Typically MacWorks Plus II will not run without the PFG installed. There may be an exception, eg. for early system versions.

For other operating environments: if the PFG is installed, I believe the only thing affected is the baud rate of Serial A / the modem port (the other features of the PFG are inactive).

Edit:
If MW+II can be made to run without the PFG, the missing features will be:
  • Extended and non-volatile PRAM (the PRAM in the stock Lisa is many fewer bytes than the Mac Plus and is not retained when power is lost),
  • compatibility with Mac Plus software that directly accesses the SCC hardware,
     and of course the main reason for the PFG:
  • Floppy disk read compatibility with disks having 3 bit-slip FF's, eg. some of those written-to by a Mac II (which cannot be read successfully by a stock Lisa).
« Last Edit: March 13, 2019, 06:29:41 pm by sigma7 »
Logged
Warning: Memory errors found. ECC non-functional. Verify comments if accuracy is important to you.

sigma7

  • Administrator
  • Full Member
  • *****
  • Karma: +22/-0
  • Offline Offline
  • Posts: 26
  • Warning: Memory errors found. Verify comments.

After checking the Hardware Reference and SCC Manuals, I see I have miscalculated baud rate errors that arise due to the whole number nature of the divisor.

I had been simply dividing the clock frequency by the baud rate and rounding to find the closest divisor. However, the 8530 SCC actually uses the following formula for the Time Constant divisor:

  TC = ( ClockFrequency / (CM * 2 * Baud Rate) ) - 2

Where CM is a selectable Clock Mode factor selected from 4 values [1, 16, 32, 64], usually 1 IIRC.

This results in slightly different values, so I'll recalculate the tables and edit them in place above if possible.

Edit:
Changes were made to the posts above in an attempt to correct the error.
« Last Edit: March 13, 2019, 10:05:20 pm by sigma7 »
Logged
Warning: Memory errors found. ECC non-functional. Verify comments if accuracy is important to you.
Pages: [1]   Go Up