6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 2:06 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: 6522 IRF and IER
PostPosted: Tue Aug 11, 2015 9:11 pm 
Offline

Joined: Sun Oct 14, 2012 7:30 pm
Posts: 107
Does anyone know the answer to this: If an IER bit is not enabled and a corresponding interrupt occurs (such as CA1), do the IRQ and/or IRF bits get set anyways? Is it possible to poll these?

Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: 6522 IRF and IER
PostPosted: Tue Aug 11, 2015 9:33 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
If a bit in the VIA's IER is clear, the corresponding bit in the IFR can be set but it will not result in IFR7 being set, nor will it pull IRQ\ down. I just tried it on my workbench computer. The latter especially makes sense, since polling multiple 65xx I/O ICs to see who caused the interrupt would initially be done with BIT IFR and branching on bit 7. Then if you find the bit 7 was set, you would further examine that IC to see what caused the interrupt. Normally you would know what to test, and there's no sense in testing for interrupts you did not enable in the IER; but if you had to, you could AND the IFR with the IER so non-enabled interrupts don't show.

_________________
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: Re: 6522 IRF and IER
PostPosted: Wed Aug 12, 2015 4:11 pm 
Offline

Joined: Sun Oct 14, 2012 7:30 pm
Posts: 107
OK, so the IFR bit can be set, even though the IER bit is cleared. This means you could poll the bit if necessary (although as you say, bit 7 would not be set). I needed to know this for emulating the 6522 in software. Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: 6522 IRF and IER
PostPosted: Sun Aug 23, 2015 4:06 pm 
Offline

Joined: Sun Oct 14, 2012 7:30 pm
Posts: 107
OK, after some experimenting I have figured out something that is not detailed in any of the datasheets (MOS, WDC, Rockwell). If the IER bit of a corresponding IRF bit is not set, then bit 7 (IRQ) of the IRF will NOT be set. The IRF bit itself will be set and that's it, not affecting the state of the IRQ output.

What I can't tell is what happens when you clear the IER bit when a IRF bit (and IRQ) are set. Does the IRQ get cleared even though this event already occurred?


Top
 Profile  
Reply with quote  
 Post subject: Re: 6522 IRF and IER
PostPosted: Sun Aug 23, 2015 5:22 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
JimDrew wrote:
What I can't tell is what happens when you clear the IER bit when a IRF bit (and IRQ) are set. Does the IRQ get cleared even though this event already occurred?


If you clear an IER bit then the corresponding IFR bit will not contribute to generating an IRQ but the condition itself if not cleared. You have to reset the flag or access the appropriate register (e.g for timer flags) to clear the condition.

For example in my SXB interrupt handler
Code:
                lda     VIA1_IFR                ; Is VIA1 the source?
                bpl     VIA1Handled             ; No.

                pha
                and     #%01000000              ; Is Timer1 the source?
                beq     VIA1T1Handled           ; No
                lda     VIA1_T1CL               ; Clear the interrupt

                inc     JIFFY                   ; Bump jiffy counter
                lda     JIFFY
                cmp     #TIMER_HZ               ; Reached a second?
                bne     VIA1T1Handled           ; No.

                stz     JIFFY                   ; Reset jiffy counter
                inc     TIME+0                  ; And bump main timer
                bne     VIA1T1Handled
                inc     TIME+1
                bne     VIA1T1Handled
                inc     TIME+2
                bne     VIA1T1Handled
                inc     TIME+3
VIA1T1Handled:

                pla                             ; Is Timer2 the source
                and     #%00100000
                beq     VIA1T2Handled           ; No.
                lda     VIA1_T2CL               ; Clear the interrupt

                lda     #%00100000              ; Disable T2 interrupt
                sta     VIA1_IER
                lda     #TX_LOCK                ; Unlock TX hardware
                trb     LOCKS
VIA1T2Handled:

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


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

All times are UTC


Who is online

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