6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 10:14 am

All times are UTC




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 55 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: [85.5] Tip of the day
PostPosted: Wed Dec 20, 2000 6:23 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Tip of the day, #5

The 6522's SR can also be used in mode 100 (shift out free-running at T2 rate) to output a 9-level PWM (0 to 8 bits high), which when followed by an RC filter, is suitable for a 9-level D/A. I've used it to generate DTMF. This is slightly better than 3-bit resolution. Some talking toys only use 2-bit resolution!

Since it's free-running in this mode, it will keep putting out the same value over and over until you give it another value. Feeding
Code:
00000000 for 0, gives  .000V output;
00010000 for 1, gives  .625V output;
00100010 for 2, gives 1.250V output;
01010010 for 3, gives 1.875V output;
10101010 for 4, gives 2.500V output;
10101101 for 5, gives 3.125V output;
11011101 for 6, gives 3.750V output;
11101111 for 7, gives 4.375V output; and
11111111 for 8, gives 5.000V output.


Image

Simplest 6522 serial port D/A converter output filter, with -3dB point at 4kHz. For driver code, go to http://wilsonminesco.com/6502primer/potpourri.html#DAC and scroll down a little 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 Sat Mar 03, 2012 7:25 am, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.6] Tip of the day
PostPosted: Thu Dec 21, 2000 5:54 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
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.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.7] Tip of the day
PostPosted: Fri Dec 22, 2000 4:33 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
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.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.8] Tip of the day
PostPosted: Sat Dec 23, 2000 4:35 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
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:
SerBugFlipFlop.jpg
SerBugFlipFlop.jpg [ 28.48 KiB | Viewed 9231 times ]

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:
SS22halfDuplx2.jpg
SS22halfDuplx2.jpg [ 58.84 KiB | Viewed 9231 times ]

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.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.9] Tip of the day
PostPosted: Sun Dec 24, 2000 5:36 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
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.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.10] Tip of the day
PostPosted: Mon Dec 25, 2000 4:55 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.11] Tip of the day
PostPosted: Tue Dec 26, 2000 5:23 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
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.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.12] Tip of the day
PostPosted: Wed Dec 27, 2000 6:43 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.13] Tip of the day
PostPosted: Wed Dec 27, 2000 6:43 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
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.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.14] Tip of the day
PostPosted: Thu Dec 28, 2000 4:10 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.15] Tip of the day
PostPosted: Fri Dec 29, 2000 4:39 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
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.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.16] Tip of the day
PostPosted: Sat Dec 30, 2000 6:57 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Tip of the day, #15

For a fast 8-bit D/A output using a 6522 port (or any parallel output port), connect an inexpensive DAC0808.  To output a new analog level, all you have to do is write the new number to the port.  That's it—no clocking, strobing, shifting, etc..  When you're not using the D/A convertor, its presence can be ignored and the port can be used as if the D/A were not even there.  This D/A has a current output, so you'll need an op amp if you want to convert to voltage.  I have used this D/A as a digital gain control too, superimposing the AC input signal onto the voltage reference.  With data convertors, make sure you reference the analog signals to the ground pin of the convertor, and not to ground elsewhere in the computer where digital noise would be a problem.  I bring these grounds out to pins on the I/O connector, then put large ferrite beads over pairs of wires of ground and analog connections.  For more details, E-mail me directly at wilsonmineszdslextremezcom (replacing the z's with @ and .).  I don't mind.  Really.

Edit: Circuit with notes at http://wilsonminesco.com/6502primer/potpourri.html#DAC

_________________
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:43 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.17] Tip of the day
PostPosted: Sun Dec 31, 2000 5:39 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Tip of the day, #16

For a fast 8-bit A/D, connect an ADC0820 to PA or PB of a 6522, 6526, etc..  Ground the A/D's mode pin.  Select the A/D with one other I/O bit from the 65xx to both the RD\ and CS\ of the A/D.  By the time a 1MHz or 2MHz 6502 gets to the next machine-language instruction to read the port, the A/D will already have the data ready.  Read it, then de-select the A/D by setting the RD\-CS\ bit high again.  (If you're running a 6502 at 200kHz or less, you can put the ADC0820 on the data bus and just read it like a memory location.)  No clocking, interrupts, etc. are needed.  It has its own track and hold too.  The Maxim MAX153 is almost identical but more than twice as fast; but it still needs a NOP before the read on my 5MHz 65c02 workbench computer to ensure dependable output.  I've used it for things like a make-shift digital 'scope, monitoring voltages and temperatures, and recording short audio snips.  8-bit audio gives a dynamic range similar to that of cassettes, but with potentially much better frequency response and distortion figures.  (Speech is intelligible with 2-bit sampling if the dynamic range is highly compressed.)  E-mail me directly for a few simple circuit considerations to consistently get accurate results.

Edit: circuit, with notes and driver code, at http://wilsonminesco.com/6502primer/potpourri.html#ADC

_________________
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:42 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.18] Tip of the day
PostPosted: Mon Jan 01, 2001 5:58 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Tip of the day, #17

You can use the 6522's PB7 and free-running T1 to output a beep signal, or clock out an exact number of cycles from an arbitrary waveform generator, while leaving the µP free to do other things at the same time.  You'll need the 2 msb's of the 6522's ACR to be 11.  You might use a timer interrupt to turn off the beep, or a cycle-counting interrupt to stop the arb at the right time.  Happy New Year.

_________________
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.19] Tip of the day
PostPosted: Tue Jan 02, 2001 3:52 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Tip of the day, #18

Use a 6522's T1 for a time reference, and T2 to count external pulses on PB6 to make a frequency counter.  The 6522's ACR<5> will need to be a 1.  Instead of using T2's interrupt-on-rollover feature, just read the T2 counter, then read it again after a certain amount of time to see how many pulses were counted in that amount of time.  You might want to have T1's rollover cause an interrupt, read T2, and then read it again at the next T1 interrupt.  For period, it might be easier to have T2 interrupt, and then read T1's counter at the interrupt.

_________________
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:41 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 55 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 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

Search for:
Jump to: