6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Sep 28, 2024 9:58 pm

All times are UTC




Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Beholder project
PostPosted: Wed Sep 23, 2015 6:13 am 
Offline

Joined: Wed Sep 02, 2015 7:28 pm
Posts: 63
Hi there.
Not sure if that's the right place, but I'm going to post my updates on my 6502 project here.
Hope that's okay :roll:

Got my 65c02 running! did both a "free run" and a "tight loop" using logic ics and the arduino.
https://www.youtube.com/watch?v=YmNbVczc618
https://www.youtube.com/watch?v=qPJ2ZzTwDSk

I have now my arduino monitoring the 65c02 and setting opcodes on the data bus. It also reads the data bus when RW pin is writing.
Haven't connected RAM yet, but hope to get it done soon :)

I wrote a simple program and so far it's working:

LDA #$03 ($A9, $03)
STA $05 ($85, $05)
JMP $0000 ($4C, $00, $00)

The program does the loading and storing, then repeats the jump. When it gets to the jump I have the arduino repeating the jump so it ends on an infinite loop. You can see the A0, A1 and A2 leds light on/off one after the other just like the version using logic ics.

When it sets the STA part I can read the 65c02 trying to store the value on address $05. The address bus shows $05, but the data bus shows $FE instead of $03 (which should be the value stored in the A register, right?) I'm almost sure its $FE... or maybe $7F

Doesn't seems like the 6502 is reseting/interrupting, it moves forward fine and the VectorPull pin doesn't trigger.
My arduino generates the clock, detects vectorpull and RW. Sets data in the dataBus when RW is reading and reads the data bus when RW is writing.
I use the RW pin to switch the 8 digital ports from input to outputs, to create a tristate. So when RW is reading the 8 ports are outputs and can send + or - Voltage. When the RW is writing, the 8 ports are set to input, thus having impedance.

Any ideas why data bus is writing this value?
Thanks for your awesome support!
Playing with a 6502 is addictive :twisted:


Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Wed Sep 23, 2015 7:35 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
The only idea I have is that the write is OK but you're looking at the bus at the wrong time, and not seeing the value which actually goes to RAM. By reading back, we'll see what did get written.
That is, assuming you have some RAM connected... perhaps you don't?

Might be a good idea to add a
LDA $05
to see what was written.

(If this is the wrong forum, Garth can move the thread to Hardware)


Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Wed Sep 23, 2015 7:40 am 
Offline

Joined: Wed Sep 02, 2015 7:28 pm
Posts: 63
Hi BigEd.
You're right, I got some bad timing when reading the data bus.
At the moment I dont have RAM connected. Im using some LEDs and the arduino to see what the 6502 spits out.
Cleaned some code and got that data bus reading bug sorted out
Now it works 100%
I can see the leds, and also read on arduino when the data bus sets the correct value after STA :)

I went ahead and added some more code for fun.
I tried:
INX ($E8)
STX $00 ($86,$00)

That worked as well!
But I did noticed something strange. After a restart, when the 6502 goes through the program again, the X register still hold the old data from before. It accumulates the data over, even when I hold reset for a while :shock:
The X register only gets back to 0 when I turn off the arduino power by disconnecting the USB cable.
Is it normal for the X register to hold data after a reset?

Sounds like another dirty bug I must fix :D
Anyhow, time to go to bed.
Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Wed Sep 23, 2015 8:28 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Good news!

Yes, I think it's normal for reset to leave the registers unchanged. Only the decimal flag and the stack pointer, I think, are actually defined at reset. Maybe some other flags??

Edit: Oops, I am reliably informed that I have this wrong! Checking the datasheets confirms it - unless someone has some evidence to the contrary, we should take it that the stack pointer is not initialised.


Last edited by BigEd on Fri Sep 25, 2015 1:31 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Wed Sep 23, 2015 6:41 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8520
Location: Southern California
and the interrupt-disable flag

_________________
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: Beholder project
PostPosted: Wed Sep 23, 2015 9:15 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
BigEd wrote:
Yes, I think it's normal for reset to leave the registers unchanged. Only the decimal flag and the stack pointer, I think, are actually defined at reset. Maybe some other flags??
yes, the interrupt-disable flag AND THE PROGRAM COUNTER! :!: :!: :!: :lol:

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Wed Sep 23, 2015 9:18 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
!!!


Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Wed Sep 23, 2015 11:52 pm 
Offline

Joined: Wed Sep 02, 2015 7:28 pm
Posts: 63
Hi Guys.
Quick question.

I've added some LEDs to both data and address bus, so I can monitor what the 6502 is doing.
I have all the LEDs negative side connected to the same 1 resistor (1K ohms), then the resistor to ground.
Is that a bad way to do it? should I have a resistor to each LED?
I works fine, but makes me wonder if it should be avoided.

Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Thu Sep 24, 2015 12:17 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8520
Location: Southern California
The more LEDs that are turned on, the dimmer they'll be.

_________________
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: Beholder project
PostPosted: Thu Sep 24, 2015 10:54 pm 
Offline
User avatar

Joined: Thu Jun 23, 2011 2:12 am
Posts: 229
Location: Rancho Cucamonga, California
BigEd wrote:
Good news!

Yes, I think it's normal for reset to leave the registers unchanged. Only the decimal flag and the stack pointer, I think, are actually defined at reset. Maybe some other flags??


The stack pointer is undefined after a reset.
Actually S gets decremented by 3 during the reset procedure because it works like an interrupt that doesn't write anything.

===Jac


Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Fri Sep 25, 2015 9:17 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
That's true for the NMOS 6502, Jac, but in this case we have a 65C02. So the stack pointer (and other bits) are initialised.
Edit: Oops, I now believe that I have this wrong! Sorry. Checking the datasheets confirms it - unless someone has some evidence to the contrary, we should take it that the stack pointer is not initialised.


Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Thu Oct 01, 2015 2:28 am 
Offline

Joined: Wed Sep 02, 2015 7:28 pm
Posts: 63
Hi again.
Ran out of cables last week. Got some more cables yesterday and added SRAM to my board.
Have everything connected according to the potpourri schematic.
Not yet working, so im troubleshooting it with my arduino, which lead me to this question:

if I use the opcode LDA($A5) $00, which has 2 bytes of length and 3 cycles... does it mean that I need to tick the 6502 3 cycles?
1 for the opcode LDA, 1 for the address $00 and an extra last one? Like, using a NOP to have the 3rd cycle?
Sorry if that sounds confusing.

So far it looks like the 6502 is resetting at the end of my code instead of falling into an infinite loop.
Here's what I got:

LDA($A9) #$03
STA($85) $00
LDA($A5) $00
JMP($4C) $00 $80 (Jump is at $8000)

the 2nd LDA is what is causing the 6502 t reset.
If I remove it, the code works and it will fall into the infinite loop.

Wondering if you guys might spot an error in my code that might be triggering the reset.

Have 6502 A15 and +v into a NAND gate. Have that output into a second NAND gate + 6502 Phase2 out. Have that output into the SRAM cs(ce) pin.
Got the 6502 R/W connected to SRAM we pin.
Have 6502 A14 connected to SRAM oe pin.
All address and data buses connected.

Will keep testing and see if I can get it to work.
Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Thu Oct 01, 2015 2:47 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1948
Location: Sacramento, CA, USA
beholder wrote:
... if I use the opcode LDA($A5) $00, which has 2 bytes of length and 3 cycles... does it mean that I need to tick the 6502 3 cycles?
1 for the opcode LDA, 1 for the address $00 and an extra last one? Like, using a NOP to have the 3rd cycle? ...

I believe that all three read cycles are necessary. Cycle one reads the op-code, cycle two reads the address operand, and cycle three reads the contents at that address, so it can be copied to the accumulator.

Mike B.


Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Thu Oct 01, 2015 2:57 am 
Offline

Joined: Wed Sep 02, 2015 7:28 pm
Posts: 63
Thanks Barry.

So does that means that I need a NOP there?
I've added a NOP and it made my code kinda work... it doesn't reset anymore. It goes into the loop.

LDA #$03
STA $00
LDA $00
NOP
STA $00
JMP $8000

Now, the weird thing is that on the second STA I can see the values in the data bus when the 6502 is outputting.
Instead of being the value #$03 it's the NOP opcode :(

Thanks for the feedback!


Top
 Profile  
Reply with quote  
 Post subject: Re: Beholder project
PostPosted: Thu Oct 01, 2015 3:17 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1948
Location: Sacramento, CA, USA
beholder wrote:
... Now, the weird thing is that on the second STA I can see the values in the data bus when the 6502 is outputting.
Instead of being the value #$03 it's the NOP opcode :( ...

Hmm ... is it possible that your Arduino code is buggy? I suspect that there are some Arduino users who could check it for you and give you some friendly advice, if you're brave enough to upload it for them to see.

Mike B.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

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