6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue May 14, 2024 9:26 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Problems with the 65c22
PostPosted: Tue May 17, 2022 12:55 pm 
Offline

Joined: Tue May 17, 2022 12:53 pm
Posts: 7
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


Top
 Profile  
Reply with quote  
PostPosted: Tue May 17, 2022 1:44 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3354
Location: Ontario, Canada
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.
Attachment:
LEDs driven by a VIA.png
LEDs driven by a VIA.png [ 2.77 KiB | Viewed 917 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


Top
 Profile  
Reply with quote  
PostPosted: Tue May 17, 2022 1:50 pm 
Offline

Joined: Tue Sep 03, 2002 12:58 pm
Posts: 298
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.


Top
 Profile  
Reply with quote  
PostPosted: Tue May 17, 2022 4:49 pm 
Offline

Joined: Tue May 17, 2022 12:53 pm
Posts: 7
I have the 65c22N.

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

Thanks a lot!

Best

Erik


Top
 Profile  
Reply with quote  
PostPosted: Tue May 17, 2022 5:24 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3354
Location: Ontario, Canada
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


Top
 Profile  
Reply with quote  
PostPosted: Tue May 17, 2022 5:30 pm 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
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.


Top
 Profile  
Reply with quote  
PostPosted: Tue May 17, 2022 7:20 pm 
Online
User avatar

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


Top
 Profile  
Reply with quote  
PostPosted: Tue May 17, 2022 9:00 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8182
Location: Midwestern USA
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!


Top
 Profile  
Reply with quote  
PostPosted: Tue May 17, 2022 10:29 pm 
Online
User avatar

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


Top
 Profile  
Reply with quote  
PostPosted: Wed May 18, 2022 4:29 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8182
Location: Midwestern USA
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!


Top
 Profile  
Reply with quote  
PostPosted: Wed May 18, 2022 5:45 am 
Online
User avatar

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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

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