6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 27, 2024 3:31 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.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: 8428
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 2130 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 2130 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: 8428
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: 8428
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: 8428
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: 8428
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: 8428
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: 8428
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: 8428
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: 8428
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: 8428
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: 8428
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: 8428
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  
 Post subject: [85.20] Tip of the day
PostPosted: Wed Jan 03, 2001 5:17 am 
Offline
User avatar

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

Do a make-shift watchdog timer for an embedded system with one of the timer/counters in a 6522.  Set it up to interrupt when it rolls over, and have your main program loop keep resetting the counter so it never rolls over as long as things are under control.  If the computer crashes with interrupts disabled, this watchdog scheme won't help unless the 6522's interrupt pin is connected to the 6502's NMI\, and it won't work if a wayward routine fowls up the 6522's setup.  (Maybe the part of the main loop that resets the counter should also re-check the set-up.)  So although it's not 100% fool-proof, it may be close enough.

_________________
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.21] Tip of the day
PostPosted: Thu Jan 04, 2001 4:12 am 
Offline
User avatar

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

I stumbled on a difference between the CMD and the Rockwell 65c22's.  The first time I used the 65c22 serial ports to pass data from one 65c02 computer to another, I used CMD's.  When I replaced it with a Rockwell, the program no longer worked.  It wouldn't get started with the first byte.  The reason was that I was checking IFR<2> to see if the SR was ready for another byte.  With CMD, this bit means "SR empty", whereas with the Rockwell, it means "8 shifts completed".  These normally mean the same thing, but my program wouldn't start with the Rockwell part because even though the SR was ready, no shifts had occurred yet because I hadn't given it anything to transmit yet.  I ended up using a RAM byte variable as a flag to tell the loop if the first byte had been sent yet.

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

Report this post
Top
 Profile  
Reply with quote  
 Post subject: [85.22] Tip of the day
PostPosted: Fri Jan 05, 2001 4:34 am 
Offline
User avatar

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

Use the 6502's NMI\ and a 6522's free-running T1 generating interrupts for a real-time clock (RTC).  Even if you don't need time and date, you can use it to time the key de-bouncing and auto repeat, time-out on hardware error (like printer not ready), etc., without using delay loops that keep the computer from doing other things while waiting.  I'm using an NMI every 10ms to update the RTC variables.  It slows the whole system down by about 1%, including looking to see if an alarm is due.  An alarm would tell the computer it's time to do a particular job.  The RTC can of course be stopped if it would cause too much jitter in another job being done in the foreground.

There is same code just over halfway down the long page of my interrupts primer.

We're often told to reserve the NMI for something drastic like power going down; but in most systems the people on this forum are making, what happens in the last milliseconds before power is gone is of no concern.  If you have a system that remembers things when it's off, it probably has batteries and can turn itself off in an orderly fashion.  There's no time to store anything useful on a disc.  If the 6522 used for the RTC goes on the 6502's NMI\, polling for interrupt sources on IRQ\ is simplified, and the RTC never misses a beat when other interrupts hit or are masked.

_________________
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:45 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 3 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: