Page 1 of 9

Writing in EEPROM and reading by 6502

Posted: Wed Dec 05, 2018 8:00 pm
by hitlp
Hi Guys,

First of all I apologize if the question that I will ask is very simple. I'm working on a personal project to assemble a 6502 PC.

The question is: I currently use the EEPROM AT28C256 directly connected to the 6502 processor. Is it addressing from 0x00000 to 0x07FFF correct?

How do I have 6502 read the FFFC and FFFD reset vectors?

My code is:

kernel.cfg
Quote:
MEMORY
{
ROM: start=$8000, size=$8000, type=ro, define=yes, fill=yes, file=%O;
}

SEGMENTS
{
CODE: load=ROM, type=ro;
VECTORS: load=ROM, type=ro, offset=$7ffa;
}
kernel.s

Code: Select all

          .setcpu "6502"
          .segment "VECTORS"

          .word   loop
          .word   loop
          .word   loop

          .code
loop:     lda #$12
          jmp loop
I asked for help .. I already researched in several sources and I can not :-(

Thanks

Re: Writing in EEPROM and reading by 6502

Posted: Wed Dec 05, 2018 8:22 pm
by GARTHWILSON
Welcome.

The 32KB EEPROM's addresses will be 0000-$7FFF, but they will show up in the range of $8000-$FFFF of the processor.

The 6502 primer should have everything you need to know.

Re: Writing in EEPROM and reading by 6502

Posted: Wed Dec 05, 2018 11:59 pm
by hitlp
Hi GARTHWILSON,

Thanks for the reply and the link. I had read enough of him but I will reread more closely.

But to be clear, I mean then when I set:
Quote:
ROM: start=$8000, size=$8000, type=ro, define=yes, fill=yes, file=%O;
does the processor read the 0x0000 as if it were 0x8000? Following this logic, 7FFC and 7FFD will be the reset vectors?

Re: Writing in EEPROM and reading by 6502

Posted: Thu Dec 06, 2018 12:08 am
by GARTHWILSON
If I understand you correctly, yes, you have it right. Various programmers' software and commands will work differently regarding things like how to tell them the offset; but as long as you end up with the right thing in the EEPROM, the target computer won't care how you got there. I'm not familiar with your particular programmer, so I don't know what the "type=ro, define=yes, fill=yes, file=%O;" part means.

Re: Writing in EEPROM and reading by 6502

Posted: Thu Dec 06, 2018 12:26 am
by Dr Jefyll
hitlp wrote:
does the processor read the 0x0000 as if it were 0x8000? Following this logic, 7FFC and 7FFD will be the reset vectors?
Yes. The processor has 16 address lines (A15-A0), and this means there are 65,636 (or 64K) possible addresses it can output.

The EEPROM has only 15 address lines (A14-A0), yielding 32K possible addresses. A15 (the sixteenth address line) from the processor is something the EEPROM and its programming software have no knowledge of. They think 32K is the entire universe! :P But your wiring should be such that this 32K starts at $8000 from the processor's POV.

Be sure to read Garth's primer. If you still have questions about your own project, it'll help if you post a schematic so we can refer to the actual wiring without guessing. (Photos are always nice, of course, and they can also be helpful.)

cheers (and welcome!),
Jeff

Re: Writing in EEPROM and reading by 6502

Posted: Thu Dec 06, 2018 2:39 am
by BillO
It sounds like you have built a prototype. Can you share the schematic you are working with and how you wish to map the memory into the 64K address space of the 6502?

Re: Writing in EEPROM and reading by 6502

Posted: Thu Dec 06, 2018 6:43 am
by whartung
Dr Jefyll wrote:
The EEPROM has only 15 address lines (A14-A0), yielding 32K possible addresses. A15 (the sixteenth address line) from the processor is something the EEPROM and its programming software have no knowledge of. They think 32K is the entire universe! :P But your wiring should be such that this 32K starts at $8000 from the processor's POV.
Even though the EEPROM has only 15 lines, if you don't handle the 16th bit (i.e. just wire up the EEPROM to A0-A14), then the entirety of your computers memory will a) be duplicated, half below $8000 and half above, and, b) will be entirely EEPROM, which can not work -- it needs 0000-01FF at a minimum as RAM.

Re: Writing in EEPROM and reading by 6502

Posted: Thu Dec 06, 2018 12:14 pm
by hitlp
Dr Jefyll wrote:
Even though the EEPROM has only 15 lines, if you don't handle the 16th bit (i.e. just wire up the EEPROM to A0-A14), then the entirety of your computers memory will a) be duplicated, half below $8000 and half above, and, b) will be entirely EEPROM, which can not work -- it needs 0000-01FF at a minimum as RAM.
This is the point I did not understand. How is half the memory divided? In my project:

-> I connected A0-A14 (from the processor) to the A0-A14 of the AT28C256;
-> The A15 of the processor is off;
-> WE is on VCC;
-> CE is on GND;
-> OE is on GND;

I know that I have to study more, but anyway thanks for the answers. :-)

Re: Writing in EEPROM and reading by 6502

Posted: Thu Dec 06, 2018 1:33 pm
by Dr Jefyll
One common arrangement -- a typical system -- is when the processor sees RAM in the bottom 32K and ROM (or EPROM or EEPROM) in the top 32K.

A0-A14 (from the processor) would attach to A0-A14 of both the RAM and the ROM. And somehow (there are various ways of arranging this) A15 of the processor would, when low, activate the RAM (via its CE, OE and WE). Likewise, when A15 is high it would be ROM that gets activated instead.

Thus the RAM (whose own internal universe is just 32K) is only active when the processor outputs addresses 0 to $7FFF -- ie, addresses with A15 = 0. The ROM (also with an internal universe of only 32K) is active only when the processor outputs addresses $8000 to $FFFF -- ie, addresses with A15 = 1.

Your present arrangement lacks any connection from A15, and the ROM (because its CE and OE are always low) is active whether A15 is high or low. IOW, when the processor asks for the lower 32K it gets ROM, and when it asks for the upper 32K it gets ROM. The ROM is active in both cases.

In this configuration you'll be able to do certain limited tests. For example, your loop should work. But it won't be long before you'll want some RAM (and I/O) attached! :)

Code: Select all

loop:     lda #$12
          jmp loop
-- Jeff

Re: Writing in EEPROM and reading by 6502

Posted: Thu Dec 06, 2018 3:55 pm
by hitlp
Dr Jefyll, wow you blowed my mind now! lol

I think that I've got now. Thanks guys! You are amazing.

Re: Writing in EEPROM and reading by 6502

Posted: Thu Dec 06, 2018 5:10 pm
by Dr Jefyll
Glad I could help. ( Golly! :shock: )

Speaking of limited tests, another one that's quite useful is to fill the ROM entirely with $EA or similar (and still with the present arrangement of ROM occupying the entire address space). This simulates the action of a so-called NOP generator, documented elsewhere on this forum (just do a search). It's a good way of verifying your existing hardware before you try adding RAM and I/O.

Re: Writing in EEPROM and reading by 6502

Posted: Thu Dec 06, 2018 7:44 pm
by whartung
As was said, since the EEPROM is always enabled, and nothing is done with A15, here's what the computer sees.

Given the addresses $2000 and $A000.

In binary, they look like this:

Code: Select all

$2000  0010 0000 0000 0000
$A000  1010 0000 0000 0000
You can see if you remove the most significant bit (A15), they both become:

Code: Select all

X010 0000 0000 0000
Which makes them identical. Both CPU addresses reference the same point in the EEPROM.

So, were you to use the CPU to "dump" the entirety of the 64K space, you'd find that the ranges $0000-$7FFF and $8000-$FFFF have identical contents.

Re: Writing in EEPROM and reading by 6502

Posted: Thu Dec 06, 2018 8:00 pm
by barrym95838
Dr Jefyll wrote:
( Golly! :shock: )
That word always seems out of place to me, but it still makes me smile, because it reminds me of those two awesome black guys from the movie Airplane:

https://youtu.be/RrZlWw8Di10

Re: Writing in EEPROM and reading by 6502

Posted: Thu Dec 06, 2018 8:06 pm
by cbmeeks
barrym95838 wrote:
Dr Jefyll wrote:
( Golly! :shock: )
That word always seems out of place to me, but it still makes me smile, because it reminds me of those two awesome black guys from the movie Airplane:

https://youtu.be/RrZlWw8Di10

LOL.

Greatest comedy of all time. I've seen it so many times that I can quote almost the entire movie.

Re: Writing in EEPROM and reading by 6502

Posted: Fri Dec 07, 2018 12:24 am
by whartung
cbmeeks wrote:
barrym95838 wrote:
Dr Jefyll wrote:
( Golly! :shock: )
That word always seems out of place to me, but it still makes me smile, because it reminds me of those two awesome black guys from the movie Airplane:

https://youtu.be/RrZlWw8Di10

LOL.

Greatest comedy of all time. I've seen it so many times that I can quote almost the entire movie.
If you love Airplane, you must watch Zero Hour, the movie that it's a remake of.

Folks think that Airplane is just a spoof on the genre of Airport movies. And while there's some truth to that, it's actually a solid scene for scene, same story, same dialog remake of the movie Zero Hour. (FYI, if you haven't seen the actual movie 'Airport', it's really good! The sequels get a bit more and more over the top, but the original is really good. I do have a soft spot for Airport '75 though.)

Trying to watch the original Zero Hour without busting out laughing is quite difficult.

TCM once ran them back to back. It was fabulous.