Hey everyone,
I'm currently at a loss.... I try to test and play with interrupts, which btw work as intended, but the RTI instruction is behaving strange...
As soon as I try to RTI, the processor is reading the wrong return address and just randomly jumps anywhere... I logged it and at Interrupt he pushed address $801A into stack, at RTI he pulled $1A1A from stack, landing somewhere in not initialized RAM and just spasms out of control...
anyone here can help?
It both happens at NMI and IRQ, RTS is working just fine, exceot when I try to RTS from the interrupt... I have no Idea what to do...
RTI behaving strangely
Re: RTI behaving strangely
With what system is this? And how are you logging addresses?
Re: RTI behaving strangely
on my own SBC I posted a while back (didn't have much time since then but now I'm tackling it again), see viewtopic.php?f=12&t=6513
I also tried to do something different. basically I tried to RTI to a specific address with the following:
with the first instruction located at $8020 thus creating a loop (checked it in the hex file)
interestingly enough this works perfectly fine, so now I am wondering...
I tried the minimal example of
which again resulted in wildly different random address accesses...
I also tried to do something different. basically I tried to RTI to a specific address with the following:
Code: Select all
lda #$80
pha
lda #$20
pha
php
rtiinterestingly enough this works perfectly fine, so now I am wondering...
I tried the minimal example of
Code: Select all
ISR:
rti
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: RTI behaving strangely
Since $1A is one of the address bytes and the $80 is lost, it kind of sounds like your ISR is not balancing the stack.
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: RTI behaving strangely
GARTHWILSON wrote:
Since $1A is one of the address bytes and the $80 is lost, it kind of sounds like your ISR is not balancing the stack.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: RTI behaving strangely
Can you post your ISR code.
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: RTI behaving strangely
ok, found something out... after back-checking with the 6502-primer here I noticed that /WE should be qualified by Phi2, so that on Phi2=low no write operation would be possible...
I hacked together a small logic circuit out of 2 NAND gates which are first inverting R/W from the 6502 and then NANDing it with Phi2. on slower clock-speeds this works perfectly well, at 1MHz the VIA doesn't issue the IRQ from the button... sooo... something is wrong with the VIA I guess?
Manual triggering of the IRQ-line works as expected now, so consider the problem solved
I hacked together a small logic circuit out of 2 NAND gates which are first inverting R/W from the 6502 and then NANDing it with Phi2. on slower clock-speeds this works perfectly well, at 1MHz the VIA doesn't issue the IRQ from the button... sooo... something is wrong with the VIA I guess?
Manual triggering of the IRQ-line works as expected now, so consider the problem solved
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: RTI behaving strangely
The WR\ to the memory needs to be separate from the signal to the VIA. Make sure you're observing that. The VIA needs the RS and R/W lines to be valid and stable before the rise of phase 2. I have never seen a VIA come defective when new, even though we used them for 13 years in one of our products. The possible exception, if I'm remembering correctly, was one where a bond wire on one of the port pins seems to have let go after it was in the field for awhile in heavy vibration. Apparently the bond was good enough to get it through initial testing, but not good enough to last.
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: RTI behaving strangely
will have a look at that later,
for now I switched the WDC 65C22S for a Rockwell R65C22P and added a pullup-resistor at the /IRQ-Pin, now it works flawlessly, even at higher clockrate
and thanks Wilson for the primer, should've read it more thorough before designing the pcb ^^
for now I switched the WDC 65C22S for a Rockwell R65C22P and added a pullup-resistor at the /IRQ-Pin, now it works flawlessly, even at higher clockrate
and thanks Wilson for the primer, should've read it more thorough before designing the pcb ^^
- BigDumbDinosaur
- Posts: 9425
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: RTI behaving strangely
From your other topic:
Why? Banking that range means the stack, among other things. I'll let you figure out the implications.
Quote:
0000 - 3FFF = Banked RAM
Why? Banking that range means the stack, among other things. I'll let you figure out the implications.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: RTI behaving strangely
BigDumbDinosaur wrote:
From your other topic:
Why? Banking that range means the stack, among other things. I'll let you figure out the implications.
Quote:
0000 - 3FFF = Banked RAM
Why? Banking that range means the stack, among other things. I'll let you figure out the implications.
Re: RTI behaving strangely
GARTHWILSON wrote:
The WR\ to the memory needs to be separate from the signal to the VIA. Make sure you're observing that. The VIA needs the RS and R/W lines to be valid and stable before the rise of phase 2. I have never seen a VIA come defective when new, even though we used them for 13 years in one of our products. The possible exception, if I'm remembering correctly, was one where a bond wire on one of the port pins seems to have let go after it was in the field for awhile in heavy vibration. Apparently the bond was good enough to get it through initial testing, but not good enough to last.
the R/W for the VIA is untouched. I lifted the /WE pin of the RAM off the board and soldered the gates directly to it. R/W for the VIA still is normal R/W