6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 12:20 pm

All times are UTC




Post new topic Reply to topic  [ 57 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
PostPosted: Tue Feb 01, 2011 3:25 am 
Offline

Joined: Tue Feb 01, 2011 3:10 am
Posts: 41
Always wanted to do digital circuitry, and the current course I am taking in university has a lot to do with it (I am doing a CompSci major). I understand a lot of the hardware (if that's the right word) about microprocessors and various digital logic devices, but nothing about electrical engineering. However I would like to do some real world projects.

I began by desoldered a 6502 variant from the original Nintendo (Only thing with a 6502 I can part with, it's broken). The instruction set is the same, and you get a few bonus built in features.

-I wired VCC to 5v, and Grn to ground.
-I wired all the data bus pins to grn for a no-op instruction
-Wired VCC/Grnd to a ossilator, and wired the clock output, to the 6502's input.
-I grounded NMI and IRQ, and put the first 4 address lines through leds.

Reset is my biggest issue. I don't have a button on me right now, but would manually switching the wire between high, to low, back to high work?

I tried doing this, but if RESET is 5v, all lines are active, and if grounded all lines are low.

Is this because the CPU is cycling too fast to see, or is it not working properly?

Just a note, the NES 6502 divides clockspeed by 12, so this may also be an issue, since I have a 5.37mhz oscillator, it's running at around 448khz.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 01, 2011 3:58 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8514
Location: Midwestern USA
ioncannon wrote:
Always wanted to do digital circuitry, and the current course I am taking in university has a lot to do with it (I am doing a CompSci major). I understand a lot of the hardware (if that's the right word) about microprocessors and various digital logic devices, but nothing about electrical engineering. However I would like to do some real world projects.

I began by desoldered a 6502 variant from the original Nintendo (Only thing with a 6502 I can part with, it's broken). The instruction set is the same, and you get a few bonus built in features.

Welcome to the wacky world of 6502s and to the forum.

Quote:
-I wired VCC to 5v, and Grn to ground.
-I wired all the data bus pins to grn for a no-op instruction

Actually, all zeros on the data bus results in a BRK instruction, not NOP. The opcode for NOP is $EA, or %11101010 in binary. So, to get NOP, wire the data bus as follows:

D0 - low
D1 - high
D2 - low
D3 - high
D4 - low
D5 - high
D6 - high
D7 - high

Quote:
-Wired VCC/Grnd to a ossilator, and wired the clock output, to the 6502's input.

Presumably you used a TTL can oscillator. It's also possible to use a crystal, or even an R-C circuit.

Quote:
-I grounded NMI and IRQ, and put the first 4 address lines through leds.

IRQ and NMI should both be high. IRQ is level sensitive and if continuously held low, causes the MPU to get stuck in an IRQ loop. Also, IRQ takes the MPU through the vector at $FFFE-$FFFF, which has to point to valid code. NMI causes a jump through $FFFA-$FFFB.

Quote:
Reset is my biggest issue. I don't have a button on me right now, but would manually switching the wire between high, to low, back to high work?

After a fashion. However, you should have a short delay upon the transition from low to high. A simple R-C circuit will suffice.

Quote:
I tried doing this, but if RESET is 5v, all lines are active, and if grounded all lines are low.

See above comments.

Quote:
Just a note, the NES 6502 divides clockspeed by 12, so this may also be an issue, since I have a 5.37mhz oscillator, it's running at around 448khz.

It could be. NMOS MPUs have a minimum clock speed below which they won't function.

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Feb 01, 2011 5:22 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
All good answers from BDD, but I think he's mostly thinking about the CMOS 6502. I don't think the NMOS one had a Schmitt-trigger input for RST\, so it needed a clean edge with a quick rise time. I can't find anything about it in the Rockwell or Synertek data sheets right now though. I do know that the NMOS ones had a die-heating problem with leaving the RST line down more than a tenth of a second or so. 50ms was what a lot of RST circuits were made to deliver. You will need more than just a switch, since the switch will produce a lot of bouncing instead of a clean RST signal. If the last low time is at least a few clock cycles long, you might be in luck, if the rise time is fast enough. Use a CMOS one and you won't have to worry about it.

The NMOS 6502 also required an external oscillator, unlike the CMOS one which could use an RC hung off the clock pins.

The NMOS 6502 was not guaranteed to work below 100kHz. The CMOS ones can be stopped without losing data from the registers, meaning you can even single-clock it with a button (with a debouncing circuit of course) so you can probe all the lines at each clock cycle if you want.

The NMOS 6502 had several bugs and quirks that got fixed in the CMOS one. The latter has more instructions and addressing modes too, so for anyone just starting out, I would definitely recommend going straight for the CMOS one. The exception is if someone wants to start programming on a Commodore 64 for example, since it used a 6502 variation that was never available in CMOS.

_________________
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: Tue Feb 01, 2011 7:28 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
ioncannon wrote:
I began by desoldered a 6502 variant from the original Nintendo (Only thing with a 6502 I can part with, it's broken). The instruction set is the same, and you get a few bonus built in features.


I believe the NES CPU lacks decimal mode, however, so software performing BCD arithmetic won't run.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 01, 2011 3:45 pm 
Offline

Joined: Tue Feb 01, 2011 3:10 am
Posts: 41
BigDumbDinosaur wrote:
ioncannon wrote:
Always wanted to do digital circuitry, and the current course I am taking in university has a lot to do with it (I am doing a CompSci major). I understand a lot of the hardware (if that's the right word) about microprocessors and various digital logic devices, but nothing about electrical engineering. However I would like to do some real world projects.

I began by desoldered a 6502 variant from the original Nintendo (Only thing with a 6502 I can part with, it's broken). The instruction set is the same, and you get a few bonus built in features.

Welcome to the wacky world of 6502s and to the forum.

Quote:
-I wired VCC to 5v, and Grn to ground.
-I wired all the data bus pins to grn for a no-op instruction

Actually, all zeros on the data bus results in a BRK instruction, not NOP. The opcode for NOP is $EA, or %11101010 in binary. So, to get NOP, wire the data bus as follows:

D0 - low
D1 - high
D2 - low
D3 - high
D4 - low
D5 - high
D6 - high
D7 - high

Quote:
-Wired VCC/Grnd to a ossilator, and wired the clock output, to the 6502's input.

Presumably you used a TTL can oscillator. It's also possible to use a crystal, or even an R-C circuit.

Quote:
-I grounded NMI and IRQ, and put the first 4 address lines through leds.

IRQ and NMI should both be high. IRQ is level sensitive and if continuously held low, causes the MPU to get stuck in an IRQ loop. Also, IRQ takes the MPU through the vector at $FFFE-$FFFF, which has to point to valid code. NMI causes a jump through $FFFA-$FFFB.

Quote:
Reset is my biggest issue. I don't have a button on me right now, but would manually switching the wire between high, to low, back to high work?

After a fashion. However, you should have a short delay upon the transition from low to high. A simple R-C circuit will suffice.

Quote:
I tried doing this, but if RESET is 5v, all lines are active, and if grounded all lines are low.

See above comments.

Quote:
Just a note, the NES 6502 divides clockspeed by 12, so this may also be an issue, since I have a 5.37mhz oscillator, it's running at around 448khz.

It could be. NMOS MPUs have a minimum clock speed below which they won't function.


Thanks for the information. I thought 00000000 was NOOP because I was using a 8085 guide as a reference. Thought some of the instructions (at least noop) would be the same. Will try the new wiring when I get home.

GARTHWILSON wrote:
All good answers from BDD, but I think he's mostly thinking about the CMOS 6502. I don't think the NMOS one had a Schmitt-trigger input for RST\, so it needed a clean edge with a quick rise time. I can't find anything about it in the Rockwell or Synertek data sheets right now though. I do know that the NMOS ones had a die-heating problem with leaving the RST line down more than a tenth of a second or so. 50ms was what a lot of RST circuits were made to deliver. You will need more than just a switch, since the switch will produce a lot of bouncing instead of a clean RST signal. If the last low time is at least a few clock cycles long, you might be in luck, if the rise time is fast enough. Use a CMOS one and you won't have to worry about it.

The NMOS 6502 also required an external oscillator, unlike the CMOS one which could use an RC hung off the clock pins.

The NMOS 6502 was not guaranteed to work below 100kHz. The CMOS ones can be stopped without losing data from the registers, meaning you can even single-clock it with a button (with a debouncing circuit of course) so you can probe all the lines at each clock cycle if you want.

The NMOS 6502 had several bugs and quirks that got fixed in the CMOS one. The latter has more instructions and addressing modes too, so for anyone just starting out, I would definitely recommend going straight for the CMOS one. The exception is if someone wants to start programming on a Commodore 64 for example, since it used a 6502 variation that was never available in CMOS.


Ahh so it wasn't just me, whenever RST was grounded, the chip would heat up significantly. Should 500khz clock be ok? I read it's due to DRAM data inside the CPU degrading if the chip is not clocked fast enough.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 01, 2011 3:47 pm 
Offline

Joined: Tue Feb 01, 2011 3:10 am
Posts: 41
kc5tja wrote:
ioncannon wrote:
I began by desoldered a 6502 variant from the original Nintendo (Only thing with a 6502 I can part with, it's broken). The instruction set is the same, and you get a few bonus built in features.


I believe the NES CPU lacks decimal mode, however, so software performing BCD arithmetic won't run.


Yea, I did some NES programming, I remember that one quirk. For now I just want to see if I can get a proper running cpu.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Feb 01, 2011 10:20 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
Quote:
Should 500khz clock be ok? I read it's due to DRAM data inside the CPU degrading if the chip is not clocked fast enough.

Yes. Just don't drop it below 100kHz unless it's CMOS. Current-production WDC 65c02's can have the clock stopped in either phase, whereas Rockwell, CMD, Syntertek, and other 65c02's could only stop with phase 2 high. NMOS ones can't stop at all without losing the data.

_________________
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 Feb 02, 2011 2:51 am 
Offline

Joined: Tue Feb 01, 2011 3:10 am
Posts: 41
Well, wired it correctly, and it still just outputs 1s on the address bus.

Got a 20mhz clock (So we are running at 1.6mhz)

Wired the Reset through this circuit to debounce http://www.all-electric.com/schematic/dbounce4.gif

Wired the data bus correctly

NMI and IRQ are wired to 5v

I am not too sure about resistors (again never did electric engineering), but maybe I need to use them instead of wires (in certain areas)?

Update: Put LEDs on the last 6 Address lines and I am seeing activity!!!! Seems it just just to fast to notice a change. However I popped a cable out by accident and now my reset is working backwords :(. Probably a cable to my not gate somewhere.

Update2: IT WORKS!!!! Problem was VCC fell out of a not gate. So cool seeing the leds count in binary. Big smile on my face.

Also means CPU isn't fried.

Now two things, for some reason the speed slows down after a while, and pressure on the cpu causes it to flicker/go fast again/pause. I am right now clocked around 450khz, maybe that's why? Going to put it back to 1.6mhz.

Update3:

Fixed the random flickering when cpu pressed, by placing the faster clock. Still have slow clock problems though.

Weird putting my hand even near (but not touching) the clock wire speeds up the clock (I AM GOD).

Have had it running for 10min now, CPU is really hot. How hot should they get normally?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Feb 02, 2011 9:53 am 
Offline

Joined: Thu Jul 08, 2010 12:53 pm
Posts: 3
Hi,

as i'm really interested by how you wired things, is it possible to have a draw of it ?

because i'm just starting to learn electronics for fun (with an Arduino) :lol:

Thanks :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Feb 02, 2011 5:24 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8514
Location: Midwestern USA
ioncannon wrote:
Put LEDs on the last 6 Address lines and I am seeing activity!!!!

You need to invest in a logic probe. You can get a reasonably good one at a reasonable price.

BTW, now that you seem to have some activity with your Frankenstein circuit, you should try to create a simple computer out of it. There is no shortage of examples around here, some that are very simple and some that aren't. :)

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Feb 02, 2011 6:52 pm 
Offline

Joined: Tue Feb 01, 2011 3:10 am
Posts: 41
BigDumbDinosaur wrote:
ioncannon wrote:
Put LEDs on the last 6 Address lines and I am seeing activity!!!!

You need to invest in a logic probe. You can get a reasonably good one at a reasonable price.

BTW, now that you seem to have some activity with your Frankenstein circuit, you should try to create a simple computer out of it. There is no shortage of examples around here, some that are very simple and some that aren't. :)


That's what my next step is :D! Blew my left over cash on components and new tools, but getting payed on Friday, so will buy some SRAM and a ROM. Going to need a eprom programmer though =\. Expensive.

Was also thinking of turning it into a small NES synthesizer. Trying to understand the schematic (http://www.freeinfosociety.com/electron ... tendo4.jpg), prof. of mine says the two pins output to a filter of some kind.

I am guessing wiring a speaker to said pins won't work...

Update: Seems the lines are literally the direct output. Saw a few "stereo sound" guides, and people tap the two pins and feed wires to two RCA ports. Going to be an interesting project :D.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Feb 03, 2011 5:34 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8514
Location: Midwestern USA
ioncannon wrote:
Going to need a eprom programmer though =\. Expensive.

Not necessarily. If all you are going to do is program EPROMs go to eBay and look for a TOP853. They sell for around 50 bucks. I have one here, and once you get past the comical English in the software, it's not bad. I use it all the time to burn EPROMs.

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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Feb 14, 2011 2:42 pm 
Offline

Joined: Tue Feb 01, 2011 3:10 am
Posts: 41
Hmm seems I may have done a little mistake. Was wiring the buses lines to a empty breadboard for better organization, and now the CPU seems to be dead. No output is coming from the address lines. The cpu isn't outputting anything. Do you think it's dead? Might have to go to value village and grab another NES lol.

Also, thanks Dino, got that eprom programmer you mentioned.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Feb 20, 2011 6:47 pm 
Offline

Joined: Tue Feb 01, 2011 3:10 am
Posts: 41
Figured out, the clock line was messed up a bit. All works now. Got the address decoder circuit wired up and it's working correctly :D!!!

Address Space is setup like this for now:

$0000-$1FFF ROM (8kb)
$2000-$3FFF RAM (8kb)

I am thinking of wiring a 7 segment display up to one address so I can output for now.

Now I have a question, on the NES CPU the RESET vector is at:

$FFFC–$FFFD 2 bytes Address of Power on reset handler routine

Will my ROM have to be positioned in that space? so instead of $2000-$3FFF it would be $E000-$FFFF? Is this the same on normal 6502's?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Feb 20, 2011 7:42 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Yes, you pretty much need ROM at the top of memory to cover the vectors and RAM at the bottom to cover zero page and the stack.

If you do a partial address decode then either or both devices can be mirrored many times over. Perhaps ROM would cover everything from $8000 to $ffff and RAM cover everything from $0000 to $7fff. The advantage is that the address decode is simpler (or minimal) - there's not much difference to the software, if you're writing your own. But it might help fit in with the expectations of software you inherit.

(As an extreme case, the Atari 2600 had just 128bytes of RAM which was mirrored in both zero page and page one for the stack.)


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

All times are UTC


Who is online

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