6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Sep 19, 2024 10:18 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Wed Dec 23, 2015 10:55 pm 
Offline
User avatar

Joined: Wed Mar 11, 2015 12:38 am
Posts: 12
Hey all, Happy Holidays to you all.

I'm trying to set up the 6522 for serial operation and I had a question about the CB1 and CB2 lines. It looks like the clock line is active low, but on reset, it looks like both CB1 and CB2 are low - is this normal?

Here's roughly my reset logic for the VIA:

Code:
lda VIA0_IER
ora #VIA_IER_SR
sta VIA0_IER

lda VIA0_ACR
ora #%00001100 // ACR[4:2] = 011 - CB2 under external clock
sta VIA0_ACR


Am I missing some software steps or are there any electrical details that I missed? Do these lines need to be pulled up?


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 24, 2015 12:01 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8509
Location: Southern California
From p.36 of the data sheet:

      3.9 Reset (RESB)

      Reset clears all internal registers (except T1 and T2 counters and latches, and the SR. In the RESB
      condition, all pins are placed in the input state and bus holding devices maintain initial level if not driven.
      The initial level can be Logic 1 or Logic 0 and are not initialized by on chip circuitry. Also, T1 and T2, SR
      and the interrupt logic are disabled from operation. [...]

Quote:
Code:
lda VIA0_ACR
ora #%00001100 // ACR[4:2] = 011 - CB2 under external clock
sta VIA0_ACR

To be sure you'll get mode 011 (particularly if you're setting it up after having used another mode since reset), you'll also need to AND-out bit 4 (since the ORA won't force it to a 0).

Unfortunately, SR mode 011 has the one and only bug in the VIA, all brands. I tell about it in tip #8 of the "Tip of the Day" column, at viewtopic.php?p=2310#p2310 . See also the section "Using the 6522's shift register for tons of input bits" http://wilsonminesco.com/6502primer/pot ... l#22_SR_IN in the "circuit potpourri" page of the 6502 primer.

You should generally activate the interrupt capability after setting up whatever it is that will do the interrupting though.

_________________
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: Thu Dec 24, 2015 3:53 am 
Offline
User avatar

Joined: Wed Mar 11, 2015 12:38 am
Posts: 12
Thanks Garth. I got my CB1/CB2 input problem solved - I miswired my DB15 connector that I'm using for Port B :-/.

Anyway, now that I've got the right inputs going into CB1/CB2 with the 7474 on the input clock, I couldn't get the 6522 to fire an interrupt. I was sure that I initialized everything. I guess by "except ... the SR" also means the internal shift counter, because you have to do one dummy load of SR to reset the counter on reset or no interrupts will ever occur, as far as I can tell. Grr!


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 24, 2015 5:46 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8509
Location: Southern California
I do empty the SR when setting it up. BIT SR is enough to do it.

_________________
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: Thu Dec 24, 2015 7:04 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8387
Location: Midwestern USA
Quote:
Code:
lda VIA0_ACR
ora #%00001100 // ACR[4:2] = 011 - CB2 under external clock
sta VIA0_ACR

If using a 65C02 or a 65C816, the above could be reduced to:

Code:
          LDA #%00001100        ;ACR[4:2] = 011 - CB2 under external clock
          TSB VIA0_ACR

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 27, 2015 8:43 pm 
Offline
User avatar

Joined: Wed Mar 11, 2015 12:38 am
Posts: 12
Thanks to you both - I've now got my AVR-based PS/2 decoder talking to the serial lines of the 6522 and am displaying text on the screen! Cheers.


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 27, 2015 8:51 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8509
Location: Southern California
Doing raster graphics on an analog oscilloscope is one of the many things I've done with the VIA's SR. The circuit is pretty simple. See viewtopic.php?p=2315#p2315 .

_________________
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  [ 7 posts ] 

All times are UTC


Who is online

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