6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 14, 2024 2:09 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: IRQ Latching
PostPosted: Wed Sep 15, 2004 8:46 pm 
Offline

Joined: Thu Sep 11, 2003 5:47 am
Posts: 45
Has any tried any kind of IRQ expansion system??

What I want to do is provide a 'seperate' IRQ for each expansion slot - up to 8 maximum. Then some how (this being the bit Im stuck on :) ) catch the IRQ's in a 8-3 encoder and also trigger the uP IRQ\ line. The uP would then read the 8-3 encoder and get a byte value indicating which lines were active and execute the routines for each interrupt handler.

It would work fine if only one interrupt could ever occur at once, but I expect that more than one interrupt could occur within a clock cycle. So how could I go about 'latching' the 8-3 inputs so it doesnt lose any interrupts??

It needs some kind of resetable buffering so that once an interrupt occurs, it stays active-low until the uP has handled it and reset the line.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Sep 15, 2004 10:10 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
There might be a way you could use the 74HC148 or '149 with some acknowledge circuitry and have the output go to a ROM whose output in turn is windowed into the IRQ\ vector in the top of the 6502 memory map.  That's a lot of complication to go to though.  Some processors are designed to do this, where the interrupt itself provides the ISR address, but their interrupt logic is quite complicated and they take a lot of clock cycles to respond to an interrupt.  The 68000 processor is one of them, and it takes an absolute minimum of 46 clocks (and up to several times that many) to begin the ISR.  Although the 6502's hardware is much simpler, the 6502 can poll a lot of sources in that amount of time!  I think you're better off with the logic in my 6502 interrupts primer.  Specifically:

A. nothing that's not set up to generate an interrupt will, so there's no sense in polling hoards of non-enabled sources;
B. you'll rarely have more than perhaps three interrupt sources enabled at once; and
C. the software can assign priorities to those interrupts when the ISRs are installed, so the most urgent ones can get serviced first when more than one hits at a time.

Remember that even with your eight interrupt lines for eight plug-in boards, each one could also have several possible interrupt sources, so some polling will still be required if any given board has more than one interrupt source enabled at once.  For example, if you have two 6522's on one of those boards, between them there could be up to 14 interrupt sources right there.  Which one pulled the IRQ\ line down?  You'll have to poll.  And that's just one of your eight boards.

One of the 6502's greatest strengths is its stellar interrupt performance.  Having a slick software method to install and delete ISRs in a list will go a long way.

_________________
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  
 Post subject:
PostPosted: Wed Sep 15, 2004 11:28 pm 
Offline

Joined: Sat Sep 11, 2004 1:04 am
Posts: 19
The 65816 (dunno about the latest 6502), has a "Vector Pull" line. Basically, it goes low during an ISR address fetch. So, could basically feed your 3 bit Interrupt number into a small EPROM along with the output of a flip-flop to select the low/high bytes of the word as needed. Or, if you don't mind a range of addresses, hardwireup as follows.

Vector Pull goes low, write $I0 to the data bus, where I is the interrupt you just generated.
Falling edge of CLK2, write $FF to the data bus. A couple of 74XX buffers would do this job very nicely, along with a flip-flop. Just use Vector Pull to enable the buffers, using the flip-flop to select which one.

Thus, your interrupts would execute as follows:
IRQ0 = $FF00
IRQ1 = $FF10
...
IRQ7 = $FF70

That gives you 16 bytes of your ROM to acknowledge the IRQ and jump off somewhere. Of course, it's quite possible that the Vector Pull line never got added to the 6502. Tho, the microcontroller version has lots of ISR entry points, suggesting that the needed logic is available on the silicon, just never brought out to pins.

The further alternate solution is to switch to the 65816. If you do not use the address bus during PHI2 high, it behaves almost exactly like a 6502, at least going upon the ease of dropping them into existing 6502 designs.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Sep 16, 2004 1:30 am 
Offline

Joined: Thu Sep 11, 2003 5:47 am
Posts: 45
What I planned to do was have a single ISR routine in the standard place which, rather than handling the IRQ's directly, would read the 8-3 encoder and the jump to the appropriate ISR's routine.

There would only be 1 IRQ line per expansion card, and it would be up to the individual routine to handle it. The actual ISR stored at $FFFx would simple go to a 'redirector' of sorts.

Assuming the IRQs were all handled via the NMI pin, the process would be something like : NMI low -> NMI ISR ( read 8-3, jmp to appropriate handler, return) -> end ISR -> continue execution


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Sep 16, 2004 5:00 am 
Offline

Joined: Sat Sep 11, 2004 1:04 am
Posts: 19
Ok, hmm, even easier, then...

IRQ lines sit HIGH normally, feed them to a 3-to-8 encoder, which normally sits at the value of 7.

Feed the outputs of the 3-to-8 encoder to a 74HC374 octal D-latch as well as a 74HC10 (three input AND gate). Connect the output of the AND gate to the IRQ# of the 6502 and the clock input of the '374 through an inverter. Tie the upper 5 bits of the '374 high (you'll see why in a moment).

When one of the IRQ lines is pulled low, the 74HC10 goes low in response. This puts a low signal into the IRQ line and interrupts the CPU. It also causes the 374 to latch the interrupt code into itself.

Then you just need to have your memory select logic activate the Output Enable of the '374 when you read the location where you want the interrupt # to show up. Hit the resulting value with an EOR #$FF and the bits tied to 1 go away, and you have your interrupt # left over!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Sep 16, 2004 5:13 am 
Offline

Joined: Sat Sep 11, 2004 1:04 am
Posts: 19
Hmm, after writing that, I see your point about latching in each new interrupt. It's almost a simpler design to simply have 8 flip-flops rather than trying to 'encode' it into 3 bits. Just set (or reset) each flip-flop, put the combined bits onto the data bus through a 244, and trigger interrupts with a unlatched set of AND gates. You can get 4 input AND gates that will keep the chipcount down.

Also, look at CPLDs. The smaller sizes come in PLCC44 cases, and you can get PLCC44 to DIP sockets that require no surface mount soldering.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Sep 16, 2004 5:24 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
Quote:
The 65816 (dunno about the latest 6502), has a "Vector Pull" line.

Yes, the WDC 65c02 has it.  It's on pin 1 if you're using the DIP.  Memory lock not (ML\) is on pin 5, and bus enable (BE) is on pin 36.  Note that pin 1 had been a second ground in earlier ones, so be careful not to ground the VP\ output.

Quote:
Assuming the IRQs were all handled via the NMI pin

You'd have to have extra hardware in that case to make sure all interrupts get detected, since NMI is edge-sensitive, not level-sensitive.  If one interrupt misses getting detected and so it does not get serviced, all your interrupts will come to an end because the line will not rise again so there will be no more falling edges.  This is discussed in the primer.

Quote:
There would only be 1 IRQ line per expansion card, and it would be up to the individual routine to handle it.

In the end you can do it however you think is appropriate for your situation of course—I just want to make sure you've considered all the options and implications first.  I have a lot of experience with 6502 interrupts.  What I may have failed to clarify was that simply knowing which board the interrupt came from may not save you much or any software polling.  You still may not know where the interrupt came from and how to service it.  There could easily be 20 or 30 possible interrupt sources on the one board, in three or four ICs, connected to the one interrupt line, giving the one ISR address from the logic you want to design.  If you have more than one possible interrupt enabled on that board and that line, You'll still have to poll in software to find out which one did it.  If it's the only board with any interrupts enabled at the time, the special hardware won't help you a bit because you already know the interrupt didn't come from any other board.

_________________
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: Google [Bot] and 30 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: