Re: 6522: can CAx and CBx used as inputs?

From: laughton_at_cyg.net
Date: Sun, 02 Jun 2024 20:15:29 -0400
Message-ID: <adae71ab8a05a47372687958bb8ac6e6_at_cyg.net>
CA1 and CB1 can be used as inputs only.  CA2 and CB2 can be used as 
outputs or inputs.

And yes, in input mode all four are mainly intended for generating an 
interrupt.  But you can "work around" that.  It's not necessary for an 
actual interrupt to occur.

Using the Peripheral Control Register (PCR), you can arrange that 
activity on CA1, CA2, CB1 or CB2 will cause a bit to be set in the 
Interrupt Flag Register (IFR).  But there won't actually be an interrupt 
because that can't happen unless you set the corresponding bit in the 
Enable Register (IER).

I said "activity", and that means you need a rising or falling edge -- 
not just a simple high or low.  Here's how you work around that.

With a DIP switch you would *normally* have a pullup resistor attached 
to the VIA pin and to one pole of the switch... And the other pole of 
the switch would be tied to *ground*.  Instead of ground, you need that 
other pole to attach to a clock signal or any other source of activity.

If the DIP switch is open then the VIA pin will stay high, and nothing 
happens.  But if the switch is closed then the VIA will "see" a 
rising/falling edge, and the bit in the IFR will get set.

(Then you'll need to clear the IFR bits again before the subsequent 
test.  IIRC, the datasheet explains how you can write to the IFR and 
clear the flags.)

Hope this helps... have fun!

Jeff / Dr Jefyll



On 2024-06-02 15:37, ruud_at_baltissen.org wrote:
> Hallo allemaal,
> 
> 
> I'm reviving some old projects with their own PCBs and I need some
> extra inputs to read some DIP switches. I have a 6522 and its CAx and
> CBx pins are not used so the idea rose to use them. But I never ever
> used them as inputs myself before and studying the data sheets, I came
> to the conclusion that these these pins can only be used as inputs to
> generate an interrupt and cannot be read like one of the PAx or PBx
> pins. That would a bit of a bummer so I hope I'm wrong.
> 
> Can anybody confirm my conclusion, or better, tell me that I'm wrong?
> 
> Thank you very much in advance!
Received on 2024-06-03 02:00:02

Archive generated by hypermail 2.4.0.