ERROR on simulating Atmega128 with AVR Studio 4.13

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please, look at the image. It seems that different names are assigned to the same addresses. Help me, please, timer 1 doesn't work, and the same for timer 3. How can i correct simulator with right addresses?

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It looks like you have NOT included the correct part description for the M128. Care to show us your code?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am having the exact same problem. I am including the io.h file from the avr include directory. When setting up the platform and the device, I was selecting "AVR Simulator" and "ATmega128". I still got the same problem that you listed.

If you look in the IO memory, assignments seem to be placed correctly according to the data sheet.

Sorry I can't help more. I'm still looking myself.

Leon...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did try a m128 project in the simulator and all the registers seem to be ok and not as above.

Quote:
I was selecting "AVR Simulator" and "ATmega128".
So that's HALF of the story,what are you telling the compiler that you are using with the include file? Can we see that bit of the code or is it TOP SECRET? If you are using C what is shown in the makefile?

....a little while later after breakfast and a good coffee...ie fully awake.. :? apologies to both of you, the registers are shown wrong both with the simulator and JTAGice, don't know what I was looking at before. The registers SHOULD be:

$2D ($4D) TCNT1H Timer/Counter1 – Counter Register High Byte
$2C ($4C) TCNT1L Timer/Counter1 – Counter Register Low Byte

Attachment(s): 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry folks, but yesterday i wasn't at home, and no,
my code is not TOP SECRET :wink: .
Here you are all my software:
I'm using codevision c for AVR, but it's not a
problem because wrong addresses are still present
using AVR Studio assembler starting from an empty
project. So, i exclude codevision c problem.
AVR Studio version is: 4.13 (the latest).
Heeeeeeeeelp i can't do anything without a correct simulation.
Tell me if you want other informations.

P.S. My code is not TOP SECRET, it's just a generated
base code by codevision C, but it's too large to post it all.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What do you mean for correct part description? When you use AVR Studio 4 assembler you haven't to include anything. It just includes header automatically!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
When you use AVR Studio 4 assembler you haven't to include anything.
Yes you do, your entry file needs to have the line .include "m128def.inc" (or whatever) to tell the assembler which processor you are using, with WinAvr the part descrition is put in the makefile.

As far as fixing up the bug you should really tell Atmel about it (they are supposed to read this forum too :) ) .You can try and put the correct addresses in the part descrition file but one is NOT supposed to.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nothing. I sent to Atmel an email and they said that simulator is not perfect and i have to use it without simulating PWMs :x . However, as you can see, in header definition files, register addresses are right.

Do this:
Make a new assembler project and put in it only
the line

bob: rjmp bob

and run it.

So you make and endless loop. As you can see, also
without including the header file, simulator
has wrong addresses. I think there's nothing i can do. Thank you for your help. If you find a solution tell me it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
they said that simulator is not perfect
Did you mention that the JTAG is also NOT PERFECT? The screen shot above is taken with the JTAG as the debugger not just the simulator and the TCNT1L and TCNT1H are definetly wrong. I'll check the m128def.inc.

Just checked both the .inc and the .XML files for the M128 and they are both correct so I don't really know what to do from here. The problem must be somewhere else, someone will know how to fix it surely :?

- 
  0x2D 
....
- 
  0x2C 
....
.equ	TCNT1L	= 0x2c
.equ	TCNT1H	= 0x2d

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SOLUTION!!! Tell me what you think about this AVR simulator: http://www.amctools.com/.
It's great, or better, it's a good simulator. Of coure, if i say that it's good that means that there's a good PWM simulation. Try it js, and tell me your opinion.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Try it js, and tell me your opinion.
I don't have time or have the need for a simulator. :) I have LOTS of real boards to work with and a few debuggers so simulation is not required. The last time I used the simulator was a long time ago when I was deciding if I should use AVRs or not.

It is a good tool for someone just starting out however but once you start working with the chips get yourself a Dragon or JTAGice.

By the way you may want to just use the simuator regardless of the above bugs, may be it is just a case of wrong address labels but the thing may works correctly as the register names are correct. Very annoying when things like that happen though.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you thought about that the 16Bit registers (Hi and LO) have temp registers to store the value while reading the other one? Perhaps this registers share the same temp register and the right value comes after the right register read.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello.

It's an error in the ATmega128.xml file.

Find this line (number 2704 in my version):

change the offset to 0x4C and you should be set.

I've reported this to Atmel.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great! THIS is a solution. However, also TCNT3 offset should be corrected to 0x88 (now it's 0x89 and T3 doesn't run). Atmel should also know this, but i don't know how to report this bug. Thank you all.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm glad it helped.

Look in the top thread in this forum called "How to report bugs in AVR Studio". I've reported this one for you, though.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also, for PWM simulation you could try the new AVR Simulator V2. m128 is one of the supported devices. It's a preview though, so there might be issues.