Quote:
It sure is nice to be able to change baud rates without having to mess with hardware. Unlike the 6551, you're not limited to 19200 baud (max programmable speed), either. I gather there are a few hard-to-find DIP UARTs out there like this if you're willing to part with $20 or more for one of them.
- Similar to the above, you can get much higher data rates out of the ACIA, still under software control-- it's just that it won't be from the 1.8432MHz crystal and the ACIA's own baud-rate generator. Instead, use the VIA's T1 in free-run mode toggling PB7 on every timeout with no further attention from the processor, and select the rate by writing to T1CL and T1CH as shown in the code above. The ACIA data sheet says the ACIA is good to 125kbps, and I suspect that that's rather conservative. 115200 is a standard bit rate, and you can get it by running the system on a Φ2 rate of 7.3728MHz (which is a standard crystal & oscillator frequency) and storing 0 in T1CL and T1CH. Then you can also get all the other standard speeds by writing different values to T1.
The bit rates shown here are exact. With adjusted T1 values, it would also work to run Φ2 twice as high, at 14.7456MHz which is another standard crystal & oscillator frequency. Other Φ2 rates would work too; but to hit the standard RS-232 bit rates exactly (or at least with an acceptable error of about 1% or less), you'll have to work around the poor granularity caused by the big jumps in PB7 output frequency that result from single-step adjustments in T1 value when it's near 0.
Code: Select all
Writing 0 to T1 gives 115200 bps. (These apply to a Φ2 rate of 7.3728MHz.) Writing 2 to T1 gives 57600 bps. Writing 4 to T1 gives 38400 bps. Writing 6 to T1 gives 28800 bps. Writing $0A to T1 gives 19200 bps. Writing $0E to T1 gives 14400 bps. Writing $16 to T1 gives 9600 bps. Writing $2E to T1 gives 4800 bps. Writing $5E to T1 gives 2400 bps. Writing $BE to T1 gives 1200 bps. Writing $2FE to T1 gives 300 bps. (The 2 goes in the VIA's T1CH.)
- Similar to the above, you can get much higher data rates out of the ACIA, still under software control-- it's just that it won't be from the 1.8432MHz crystal and the ACIA's own baud-rate generator. Instead, use the VIA's T1 in free-run mode toggling PB7 on every timeout with no further attention from the processor, and select the rate by writing to T1CL and T1CH as shown in the code above. The ACIA data sheet says the ACIA is good to 125kbps, and I suspect that that's rather conservative. 115200 is a standard bit rate, and you can get it by running the system on a Φ2 rate of 7.3728MHz (which is a standard crystal & oscillator frequency) and storing 0 in T1CL and T1CH. Then you can also get all the other standard speeds by writing different values to T1.