0

I have code for ATMEGA128. It should be a counter program from 0 to 9.

#include "iom128v.h"
#include "macros.h"

void delay(int ms)
{
 int c1, c2;
 for(c1=0;c1<ms;c1++)
  for(c2=0;c2<970;c2++) NOP();
}

void main()
{
 char seg[10]={0b01110111, 0b01100000, 0b00111110, 0b01111010, 0b01101001,
  0b01011011, 0b01011111, 0b01110000,0b01111111, 0b01111011};
 char i;
 DDRC=0b10000111;
 DDRA=0xFF; 
 DDRG=0x01; 
 PORTG=0;   
 PORTA=0;   
 PORTC=0;   
 PORTC=5;   
 PORTC=7;   
 PORTA=0xFF; 
 PORTC=1;        
 PORTC=2;        
 PORTC=6;        
 while(1)
 {
  for(i=0;i<10;i++)
  {
   PORTA=~seg[i];  
   delay(300);  
  }
 }
}

I run this code in proteus and get the following errors cycled

PC=0x00FC. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21E1]=AA. [U1]

PC=0x0132. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21FF]=99. [U1]

PC=0x0132. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21FE]=00. [U1]

PC=0x0168. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21D6]=21. [U1]

PC=0x016A. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21D5]=D7. [U1]

PC=0x016C. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21D4]=02. [U1]

PC=0x016E. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21D3]=00. [U1]

PC=0x0174. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21FD]=BA. [U1]

PC=0x0174. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21FC]=00. [U1]

PC=0x01E0. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21D2]=0A. [U1]

PC=0x01E2. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21D1]=02. [U1]

PC=0x01E4. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21D0]=D7. [U1]

PC=0x01E6. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21CF]=21. [U1]

PC=0x01E8. [AVR MEMORY] External Memory Write while interface is not enabled (SRE=0): [0x21CE]=7B. [U1]

PC=0x01EA. [AVR MEMORY] External Memory Read while interface is not enabled (SRE=0): [0x21D5]. [U1]

PC=0x01EC. [AVR MEMORY] External Memory Read while interface is not enabled (SRE=0): [0x21D6]. [U1]

PC=0x01EE. [AVR MEMORY] External Memory Read while interface is not enabled (SRE=0): [0x21D3]. [U1]

PC=0x01F0. [AVR MEMORY] External Memory Read while interface is not enabled (SRE=0): [0x21D4]. [U1]

PC=0x0202. [AVR MEMORY] External Memory Read while interface is not enabled (SRE=0): [0x21CE]. [U1]

PC=0x0204. [AVR MEMORY] External Memory Read while interface is not enabled (SRE=0): [0x21CF]. [U1]

PC=0x0206. [AVR MEMORY] External Memory Read while interface is not enabled (SRE=0): [0x21D0]. [U1]

PC=0x0208. [AVR MEMORY] External Memory Read while interface is not enabled (SRE=0): [0x21D1]. [U1]

PC=0x020A. [AVR MEMORY] External Memory Read while interface is not enabled (SRE=0): [0x21D2]. [U1]

PC=0x000E. [AVR MEMORY] External Memory Read while interface is not enabled (SRE=0): [0x21FC]. [U1]

PC=0x0174. [AVR MEMORY] External Memory Read while interface is not enabled (SRE=0): [0x21FD]. [U1]

PC=0x0000. [AVR CPU] RET address = 0x0000 [U1]

8
  • Looks like you're having trouble reading and writing external memory while the interface is not enabled. Commented May 20, 2020 at 6:13
  • Did this help at all electronics.stackexchange.com/questions/62089/… looks like you could be selecting the wrong device type in proteus simulation? Commented May 20, 2020 at 6:17
  • How can i fix this? I don't know what interface is not enabled. Commented May 20, 2020 at 6:18
  • Make sure the device you included in proteus (it's a schematic layout program, correct?) matches the device you compiled the code for. I don't have experience with either of these so I'm kind of stabbing in the dark unfortunately. Commented May 20, 2020 at 6:24
  • 1
    Your teacher can be wrong. Commented May 20, 2020 at 6:32

2 Answers 2

0

Your code doesn't seem to use external memory. This access must stack access. Check for stack address. Of course, Proteus has a lot of weird behaviors in simulation.

In case of eXternal MEMmory access: You must set SRE bit on MCUCR register to enable External Memory Interface. Also check configuration for MCUCR.SRW10, XMCRA and XMCRB. XMCRA and XMCRB are not accessible on ATmega103 compatibility mode (M103C fuse programmed). When SRE bit is set, the A, C and G[2:0] will be dedicated to XMEM interface (instead of normal GPIO port). (Also see for better busy-wait delay automated base on F_CPU macro.)

Sign up to request clarification or add additional context in comments.

Comments

0

There is limitation of simulation of external memory in proteus, so avoid using external memory. I have done many programs but avoided external memory, kindly check proteus website.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.