[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Info about setting the SCC baud rate needed
In article <36omv1Ecm1@uni-erlangen.de>,
Alexander Krauss <sz0475@cd4680fs.rrze.uni-erlangen.de> wrote:
>
> does anyone have information on how to set the baudrate timer registers
> of the SCC in the IIGS (to higher baudfrates than 19200 :) )
Yes. (At least, I can work it out since I have the documentation for
the chip and for the IIgs firmware.)
> if think they just should hold the values to divde the chip clock by
> 2...
Nope. Calculating the baud rate divisor for the SCC is a little tricky.
The baud rate divisor produces a square wave signal that is fed into
the transmit and receive circuitry in the SCC. When you're sending
asynchronous data, these circuits need to be provided with a clock
that is 16, 32 or 64 times the data rate. For example, at 9600 bps,
you need to provide a 153.6 kHz clock signal, assuming the SCC is set
to x16 mode.
There is also a divide-by-two on the output of the baud rate generator.
The data rate and baud rate generator time constant are related by
these formulae:
TIME_CONSTANT = CLOCK_FREQUENCY - 2
-------------------------
2 * CLOCK_MODE * BIT_RATE
BIT_RATE = CLOCK_FREQUENCY
------------------------------------
2 * CLOCK_MODE * (TIME_CONSTANT + 2)
The CLOCK_FREQUENCY is 3.6864 MHz (3686400). CLOCK_MODE is 16, 32 or
64 (I'm pretty sure the IIgs is set to x16 mode).
The time constants for high bit rates are therefore:
Bit Rate Time Constant
---------------------------
9600 10
11520 8
12800 7
14400 6
19200 4
28800 2
38400 1
57600 0
It may also be possible to set the SCC to run at 230400 bps in
asynchronous mode, by clocking the transmitter and receiver directly
from the crystal, bypassing the baud rate generator. I haven't tried
this, and I doubt it would be of much practical use, unless you had a
very fast IIgs. It would also be more difficult, as it requires
reprogramming several other SCC registers, some of which may be
updated by the firmware for certain operations. I think this would
only be an option if you were completely bypassing the firmware.
> But if I try to read out the values I always get the same ...
Don't forget to initialize the serial firmware BEFORE you try to write
to the registers. Every time you initialize the firmware, or you use
the "Ctrl-A nn B" command, the SCC registers will be set to the
firmware's baud rate value. In particular, if you try to set the baud
rate and then run a program which initializes the firmware, it will
override your setting.
Using SetSCC to change the values then reading them back with GetSCC
should return the values you set.
> I tried to use the firmware commands decribed in the apple manuals
> but to no avail.
Assuming the firmware is already initialized, all you have to do is
write the divisor to write register 12 (low byte) and 13 (high byte).
This should be done while no data is being sent or received.
Officially, you are supposed to disable the receiver, transmitter and
baud rate generator first, but I doubt this is a problem. Set the
high byte first, in case it is currently running at a low baud rate.
> The clockrate of` the SCC is 3.6064 so all baudrates up to the half of
> that should be able to be used (i'm i wrong), appletalk for example does
> it's stuff at 115kbaud i think, so how to programm those two registers ?
LocalTalk is actually 230400 bps. It is using FM-based self-clocking
SDLC (bit synchronous) mode, using the DPLL to recover the clock from
received data and to generate the transmit clock. The baud rate
generator is running in x1 mode to provide a timing reference for the DPLL.
This is a totally different situation from using the SCC for
asynchronous communications.
--
David Empson
dempson@actrix.gen.nz
Snail mail: P.O. Box 27-103, Wellington, New Zealand