Problems with the 65c22

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
Erik
Posts: 7
Joined: 17 May 2022
Contact:

Problems with the 65c22

Post by Erik »

Hi there,



I have some strange problems using the 65c22 VIA-Chip.

If I use Port-B to control some LEDs, it works fine.

But if I switch to Port-A, the LEDs shine very weak .

I switched to an original VIA 6522 but it looks the same.



I certainly make a stupid mistake, but I do not find.



Best



Erik
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: Problems with the 65c22

Post by Dr Jefyll »

Welcome, Erik :)

What you're seeing is probably normal. Can you give us more info?

There are two different ways to connect an LED to a port pin, as shown below. (A resistor may also be present but that's not shown.) Please tell us if your LEDs connect to +5 or to Ground.
LEDs driven by a VIA.png
LEDs driven by a VIA.png (2.77 KiB) Viewed 1323 times
Variations are also possible in the programming. An LED can be switched on & off by manipulating the DDR register alone, or the DDR in combination with the OR. Can you share your code with us?

-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
John West
Posts: 383
Joined: 03 Sep 2002

Re: Problems with the 65c22

Post by John West »

The two ports are not the same. WDC's documentation is not very clear, but it looks like port B is the one that's intended for sourcing higher currents. Both ports can sink more than port A can source, and B can source more than either can sink. I think. It's confusing. And it also depends whether you've got a 65C22S or 65C22N.

Are you driving the LEDs through a resistor to 0V? That's asking the 6522 to source current, which port A isn't good at. If you turn the LED around and connect it to 5V, and invert the signal you're writing to the port, you might get better results on port A.

Or just use a buffer like the 74HC541. That can provide plenty of current in both directions.
Erik
Posts: 7
Joined: 17 May 2022
Contact:

Re: Problems with the 65c22

Post by Erik »

I have the 65c22N.

And yes, to solve the problem, I schould use a 74LS244.

Thanks a lot!

Best

Erik
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: Problems with the 65c22

Post by Dr Jefyll »

Erik, it's OK if you want to use an 'LS244 (or an 'HC541 as John suggested). However, it is not necessary to use any extra chip. If you connect your LEDs with the anodes going to +5 (as shown on the left of my diagram) I think you'll find that Port A and Port B both cause the LEDs to shine brightly.

No additional parts are required, so that means no extra cost or board space. :wink: But the program might need some minor changes. We can guide you on this, but please show us the code you're using now.

-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
gfoot
Posts: 871
Joined: 09 Jul 2021

Re: Problems with the 65c22

Post by gfoot »

If you are going to buffer it after all, it might be worth getting a proper constant-current LED driver IC. You'd need fewer resistors as well that way.
User avatar
GARTHWILSON
Forum Moderator
Posts: 8775
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Problems with the 65c22

Post by GARTHWILSON »

The diagrams on pages 32-35 of the W65C22N & S data sheet at http://6502.org/documents/datasheets/wd ... 3_2010.pdf show the differences between the N & S versions and other brands. The S has very strong symmetrical outputs on both port A and port B, and a few other benefits over the N.
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?
User avatar
BigDumbDinosaur
Posts: 9428
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Problems with the 65c22

Post by BigDumbDinosaur »

Erik wrote:
I have the 65c22N.

The -N version has current-limiting features on the outputs to emulate the original NMOS part. The -S version does not, and also has a totem-pole IRQ output vs. the -N version’s open-drain IRQ.

Quote:
And yes, to solve the problem, I schould use a 74LS244.

As Jeff said, buffering the VIA’s outputs to drive a smallish LED isn't necessary. With the -N version, tie the LED to VCC through a resistor and have the VIA pull the output down to activate the LED. That takes advantage of the VIA’s output characteristics.

As an aside, use of 74LS logic is not recommended in new designs. Some logic families you should consider for 5 volt applications are 74HC(T), 74AHC(T) and 74AC(T). Of the three, 74HC(T) is the slowest, with propagation times equivalent to or slightly worse than 74LS. 74AHC(T) and 74AC(T) are fast, with many parts operating with single-digit prop times. 74HC(T) and 74AHC(T) can source and sink 8 mA. 74AC(T) can source and sink 24 mA.

I used to recommend 74AC(T) in designs looking for maximum performance. However, the extremely fast edges of that logic type can introduce severe ringing in some cases, which may result in instability. 74AHC(T) performs at equivalent speeds, but has “gentler” outputs that reduce a circuit’s propensity for ringing.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
GARTHWILSON
Forum Moderator
Posts: 8775
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Problems with the 65c22

Post by GARTHWILSON »

Quote:
And yes, to solve the problem, I schould use a 74LS244.
I missed that earlier. According to my experiments, the W65C22S can pull 19mA to within 0.8V of either rail.
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?
User avatar
BigDumbDinosaur
Posts: 9428
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Problems with the 65c22

Post by BigDumbDinosaur »

GARTHWILSON wrote:
Quote:
And yes, to solve the problem, I schould use a 74LS244.
I missed that earlier. According to my experiments, the W65C22S can pull 19mA to within 0.8V of either rail.
19 mA is more than enough to drive a standard LED.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
GARTHWILSON
Forum Moderator
Posts: 8775
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Problems with the 65c22

Post by GARTHWILSON »

BigDumbDinosaur wrote:
19 mA is more than enough to drive a standard LED.
Yep, and it could do even more because you don't need to bring it that close to the rail. If you just short a 22S pin to the opposite rail, you'll get about 50mA (although I didn't try to see how long you'd have to short it to burn out the pin driver on the die). 20mA was considered kind of a standard current for driving LEDs in the early days; but modern LEDs are so much more efficient that 10mA would be blinding if we're just talking about an indicator you look at directly. I usually only use around 10% of that much. The 22S should give about 4.9V @ 2mA. A red LED takes around 1.7V; so 4.9V-1.7V is 3.2V, and that divided by 2mA is 1.6K. 1.5K is more common and will be adequate. 1K would give a little over 3mA. Modify that for other colors which will take more voltage. Note that the curves are definitely not linear. I have actually used LEDs for low-voltage non-precision voltage references at work. The following graph appears to be for bigger LEDs than we're probably talking about here, taking higher current. Smaller LEDs will take a higher voltage at any given current, and in the upper 2/3 of the graph, might produce smoke:
Image
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?
Post Reply