Is there a bug in AVRStudio 4.10, STK500 or the Mega16?

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

I'm writing a quiet large program for the Mega16 in AVR studio 4.10 It works just fine until my program reach flash memory 2454 bytes or 994(hex). The Mega16 should accept code up to 16 kbytes. This means I've only used about one third of it's capacity. If I exceed this by just writing one "nop" anywhere in the code and flash the microcontroller, the microcontroller fails! It took some time until I figured it out.
I've reduced the problem into a few lines. The program makes two LED’s toggle when connected to PB2 and PB3. There is one "nop" in the "main-loop". Now, “cut-and-paste” all the "nop" 's below the interrupt routine into the "main-loop". Flash the microcontroller. It should still work. Now, add just one more "nop", flash again and the Mega16 fails!
Does anyone have any theory about this phenomenon :roll:

Attachment(s): 

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

Hello.

rjmp has a limited range, and my guess is that you just hit that limit. Try to use jmp instead and see if that helps.

If you are using AVRASM 2 (you can select it in AVR Studio somewhere), it will tell you if you try to jump/branch too far (i don't think AVRASM 1 does).

Did you try to simulate? That may also give some hints.

-Geir

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

As I said in the other place you posted, the assembler doesn't flag out of range RJMPs.

There's another bug in the simulator, interrupts and calls work even if you don't initialize the stack pointer.

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

Thanks mneary :) Sometimes I'm blind.. Sometimes one just sort out a solution too easy..Anyway; there is a good attitude in this forum. Thanks to all of you!