|
Offline
Joined: Fri Aug 30, 2002 1:09 am Posts: 8724 Location: Southern California
|
Tip of the day, #6
Without bit-banging, you can also use the 6522's synchronous serial port in mode 101 for limited, but relatively fast, RS-232 output (adding a line driver). CB1 need not be connected for this. Since T2 only uses its counter's low byte to control the baud rate, the slowest you can go at 2MHz is about 4800 bps. To go slower, use mode 111, even if you use T1 and PB7 on the same 6522 to supply the external CB1 clock. RS-232 goes out low bit first, so you'll have to reverse the bit order in software.
You could conceivably get all 8 data bits + start and stop (who uses parity?) by making a word extend across the boundaries of consecutive SR operations, but you'd probably add a 6551 if you really needed the full RS-232 complement. Otherwise, since the 6522's SR only gives 8-bit frames and you need start and stop bits, you're left with 6 bits for data. With this 40H range, you can still get every character you see on your keyboard (no lower case) by subtracting a 20H offset from the ASCII value. If the receiving computer is set for 7 or 8 data bits, the last bit(s) will always be high because of the early stop bit. Add 40H or C0H, plus your offset, to make the data conform to ASCII again. If your offset excludes needed characters like CR and LF, you can substitute characters you don't need— maybe \ and _ . The short word will usually require leaving a couple of bits' extra time before starting the next byte, to ensure that the receiving computer sees a valid stop bit.
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
Last edited by GARTHWILSON on Wed Feb 22, 2012 8:08 am, edited 2 times in total.
|
GARTHWILSON
Post Posted: Fri Dec 22, 2000 4:33 am
|
Offline
Joined: Fri Aug 30, 2002 1:09 am Posts: 8724 Location: Southern California
|
Tip of the day, #7
Similar to tip #4, you can use the 6522's SR for inputting hundreds of bits as well, typically using mode 001 or 010 and a daisy chain of something like the 74HC165 or '597. For input at a different voltage, you can use the LM339 comparator between a chain of 4021's and the 6522. Again, hundreds or even thousands of bits can be interfaced to a single 6522 this way.
Image
For more description, see the section of the potpourri page of my 6502 primer where you see the same diagram as above.
There is a bug in all brands of 6522 in mode 011 however. See my next tip.
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
Last edited by GARTHWILSON on Wed Feb 22, 2012 8:07 am, edited 2 times in total.
|
| Top |
|
GARTHWILSON
Post Posted: Sat Dec 23, 2000 4:35 am
|
Offline
Joined: Fri Aug 30, 2002 1:09 am Posts: 8724 Location: Southern California
|
Tip of the day, #8
The 6522 has a bug in mode 011, shifting synchronous serial data in under control of external CB1 clock. All brands have this bug. If the edge on CB1 falls within a few nanoseconds of the falling edge of phase 2, the CB1 edge will be ignored, so you lose a bit. Worse, you'll get framing errors on subsequent data. To get around it, put the external clock signal into the D input of a 74HC74 flip-flop, run the flip-flop's Q output to the 6522's CB1 pin, and clock the flip-flop with phase 0 or phase 2. I have used this to send data from one 6502 computer to another using CA2 for an extra handshake line.
Attachment: The SPDT switch in the diagram is for direction (up for CB1=output and down for it being an input), and could of course be replaced with 74-family parts to control the switching with software, something like the following which comes from my SS22 interface article:
Attachment: Edit, many years later: Mode 111 (shift out under control of an external shift clock) is also affected by the same bug. I had missed that earlier.
Edit, 1/18/24: Forum member Andre Fachat posted some test results linked in his post at viewtopic.php?f=4&t=7937 (and my post here shows up in his video :D ).
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
Last edited by GARTHWILSON on Wed Feb 22, 2012 8:15 am, edited 1 time in total.
|
| Top |
|
GARTHWILSON
Post Posted: Sun Dec 24, 2000 5:36 am
|
Offline
Joined: Fri Aug 30, 2002 1:09 am Posts: 8724 Location: Southern California
|
Tip of the day, #9
To get the 6522's T1 running in free-run mode, you must set bit 6 of the ACR before writing to the counters. Then, write to T1's counters to get it started. After that you can write to the latches. (This requirement may not hold for all manufacturers.) It took me a long time to get this going the first time since this information is not in the data books. I finally got it by looking at a working program that an applications engineer at Rockwell sent me.
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
Last edited by GARTHWILSON on Wed Feb 22, 2012 8:16 am, edited 1 time in total.
|
| Top |
|
GARTHWILSON
Post Posted: Mon Dec 25, 2000 4:55 am
|
Offline
Joined: Fri Aug 30, 2002 1:09 am Posts: 8724 Location: Southern California
|
Tip of the day, #10
When you're not using a 6551 ACIA for serial communication, you can use the RTS\ and DTR\ as extra output bits. Be aware, however, that the 6551 ACIA needs a toggling signal at the XTAL 1 input for some internal operations, so don't just stop clocking it when you're not using the serial I/O.
Merry Christmas (It won't be Christmas here for a few more minutes)
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
|
| Top |
|
GARTHWILSON
Post Posted: Tue Dec 26, 2000 5:23 am
|
Offline
Joined: Fri Aug 30, 2002 1:09 am Posts: 8724 Location: Southern California
|
Tip of the day, #11
The MIDI (musical instrument digital interface) bit rate is 31,250bps, which is not a standard rate option for the 6551 ACIA with a 1.8432 MHz crystal. To get it, set the 6551 for one-sixteenth of the XTAL clock input rate, and then feed it with 500kHz instead of 1.8432MHz. Get the 500kHz off of a 6522's PB7 from its free-running T1. If you have a 6522 put out a steady square wave on PB7 from T1, the frequency is: f=Ph2/(2(n+2)), where Ph2 is the phase-2 system clock frequency, and n is the T1 latch value.
Similarly, you can get much higher bit rates from the ACIA, still under software control. Hitting all the standard RS-232 speeds up to 115200 bps is shown 90% of the way down the page at http://wilsonminesco.com/6502primer/IO_ICs.html .
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
Last edited by GARTHWILSON on Wed Feb 22, 2012 8:17 am, edited 1 time in total.
|
| Top |
|
GARTHWILSON
Post Posted: Wed Dec 27, 2000 6:43 am
|
Offline
Joined: Fri Aug 30, 2002 1:09 am Posts: 8724 Location: Southern California
|
Tip of the day, #12
The capacitors of approximately 15 to 22 pF from the XTAL terminals of the 6551 ACIA to ground are not just to make the crystal frequency more acurate. If that were all they were for, you'd normally be close enough without them. But if you don't have a capacitor at least on XTAL 1 (the input) when using a crystal connected from XTAL 1 to XTAL 2, spurious components on the internal crystal oscillator's waveform may keep the baud rate generator from working at all.
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
|
| Top |
|
GARTHWILSON
Post Posted: Wed Dec 27, 2000 6:43 am
|
Offline
Joined: Fri Aug 30, 2002 1:09 am Posts: 8724 Location: Southern California
|
Tip of the day, #12 (duplicate-- How did that happen? So I'll replace it with Tip 12-A, bringing it in from here)
Tip of the Day, #12-A For simple raster graphics using an analog oscilloscope in X-Y mode, you can built a circuit whose counter ICs are fed from the clock line of a 6522's synchronous-serial port, whose data line goes to the Z-axis input. Here's a photo:
Image
Here's a simplified schematic of it (just omitting some resistors and capacitors):
Image
It just takes three pins of the 6522: two for the serial interface and one to reset the frame to start. As you can see, you could make any character you want, any font, and monochrome binary graphics. The 6522 takes constant babysitting though, so to keep the display going while your processor does something else, one way would be to make a separate, very simple computer to take the data and buffer it and run the display.
I should probably interlace it to cut the perceived flicker when scanning a lot of rows at a rate that everything can handle. (The Z-axis input of this scope was not able to handle the data as quickly as the computer could send it out.) It would requiring switching a couple of wires and changing the software. The down side would be that the frame height in number of lines can't change on the fly. I'd have to put in a DIP switch.
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
Last edited by GARTHWILSON on Mon Mar 05, 2012 6:46 am, edited 2 times in total.
|
| Top |
|
GARTHWILSON
Post Posted: Thu Dec 28, 2000 4:10 am
|
Offline
Joined: Fri Aug 30, 2002 1:09 am Posts: 8724 Location: Southern California
|
Tip of the day, #13
If using more than one 6551 ACIA without a dedicated external clock oscillator, you can drive them all off of a single 1.8432MHz crystal by connecting the XTAL 1 pin (input) of secondary 6551's to the XTAL 2 (output) pin of the primary one that has the crystal. My workbench computer has 3 6551's, and one of them has a choice, selectable through DIP switches, of using either the 1.8432MHz, or VIA3PB7 for MIDI, as mentioned in tip #11. Having 3 switches gives the option to use separate transmit and receive clocks.
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
|
| Top |
|
GARTHWILSON
Post Posted: Fri Dec 29, 2000 4:39 am
|
Offline
Joined: Fri Aug 30, 2002 1:09 am Posts: 8724 Location: Southern California
|
Tip of the day, #14
When servicing 6551 ACIA interupts for simultaneous transmission and reception, remember that reading the status register clears the interrupt, but the interrupt could have been caused by both TX register empty and RX register full at the same time. If your ISR ends before finding all the interrupt causes, it may, for example, find the receive register full, service that, and then exit thinking it's done, when in actuality the transmit register emptied before you read the status register and it's waiting for the next byte. Now the IRQ line is false and the issue will never be addressed, and transmission will come to a halt. If more than one thing in the same IC could need service, make sure the ISR doesn't stop before the whole job is done.
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
Last edited by GARTHWILSON on Wed Feb 22, 2012 8:22 am, edited 1 time in total.
|
| Top |
|
Who is online
Users browsing this forum: No registered users and 0 guests
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum