-1

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

STT
  • 59
  • 6
  • 1
    Looks like you are using Atmega103 compatibility mode (Memory Configuration B). In this mode external memory is mapped to 0x1000, so 0x1100 address becomes 0x100 from beginning of external memory. – dimich May 07 '23 at 19:32
  • @dimich what would be the correct configuration for ATmega128? I guess I am looking at the datasheet wrong – STT May 07 '23 at 19:40
  • 1
    See Table 117, M103C bit. – dimich May 07 '23 at 19:46

2 Answers2

1

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.

vvv444
  • 2,764
  • 1
  • 14
  • 25
  • So that means I have to disable the compatibility mode right? I looked it up like dimich suggested and found out how I can change some fuse values in Proteus by double clicking on the MCU. But I don't see anything related to the compatibility mode. There was no extended fuse there. – STT May 07 '23 at 19:56
  • @STT I must admit I never used Proteus. Just looked in the datasheet now. It's been over 10 years since I last programmed AVR myself :-D And yeah, dimich beat me while I was reading the datasheet and writing the answer. And yes, seems you have to disable the mode or just use the memory assuming it starts at 0x1000. – vvv444 May 07 '23 at 20:13
  • Can you post somewhere screenshot of settings you see when you double click the MCU? – vvv444 May 07 '23 at 20:19
  • I will send that screenshot in about 30 minutes – STT May 07 '23 at 20:19
  • @STT Interesting answer from 2020 [here](https://stackoverflow.com/a/62309155/2059689) – vvv444 May 07 '23 at 20:20
  • I never used Proteus as well hahaha but school project so I gotta do what I gotta do – STT May 07 '23 at 20:20
  • I added the screenshots of the settings :) – STT May 07 '23 at 22:52
1

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

KIIV
  • 3,534
  • 2
  • 18
  • 23
  • This is exactly what I did! Took some time to figure it out but I am glad that this is a valid solution. – STT May 12 '23 at 07:05
  • Yes, it's bit annoying the ext memory doesn't start after internal memory with 0, but if you need more memory, you can always choose better mcu. For example AVR128Dx with 16kB of SRAM, Atmega1280 8kB, ... – KIIV May 12 '23 at 08:04