Connecting 6116 to ATMega128

134 Views Asked by At

I have been trying to connect a 6116 to an ATMega128 in Proteus. I have the following schematic: enter image description here

I can somewhat write to 6116 but I don't think I am accessing to correct addresses. I used the following code to test if everything was working correctly:

.include "m128def.inc"

        ldi r16, 0x80 
        out MCUCR, r16

        clr r16
        sts XMCRA, r16
        
        ldi r16, 0x03
        sts XMCRB, r16
        
        ldi r16,1
        sts 0x1100, r16

        here: jmp here

So when I run this code, I expect to see value 1 at $0000 of 6116. However, this is what I see: enter image description here

value 1 appears at $0100 of 6116. What am I missing here, what is wrong? I am extremely new to this and sorry if I butchered something.

Edit: Here are the settings that I get when I double click on the MCU enter image description here

2

There are 2 best solutions below

2
KIIV On BEST ANSWER

I'm pretty sure if you write to address 0x1100, you'll get the location 0x100 in the 6116 for both configurations. You should start at 6k boundary (0x1800 = 0b1100000000000 => 0b**00000000000) to be sure you are starting at 0x0000 in external memory.

enter image description here

For 2kB memory you'll have to count on the address "masking" = you don't have the address lines available:

enter image description here

Of course in 103 compatibility mode (memory configuration B) you could've start on 4k boundary, instead of 6k

7
vvv444 On

I think you run the chip in "ATmega103 compatibility mode" which is selected by the M103C fuse bit. That's the default value of the fuse (See ATmega128 datasheet page 287).

In this compatibility mode, "Memory configuration B" is in use (from datasheet page 32):

Memory configuration B refers to the ATmega103 compatibility mode, configuration A to the non-compatible mode.

enter image description here

Thus, memory address 0x1100 refers to address 0x100 in the external RAM.

Also, it might be that Proteus simulation just doesn't entirely support all the external memory modes.