EmbeddedRelated.com
Forums
Memfault Beyond the Launch

AVR ATMega16

Started by clark March 28, 2006
Greetings all,

In trying to assist an associate with problems developing code for an
RF comb filter board designed around a Mega16, things are, well,
actting really weird, to say the least.  It almost seems to be a
development tool problem, but I am really baffled.  I am using ICCAVR
(6.28C), AVR Studio (4.11, build 10, SP3), and a JTAGICE mk II
emulator.

This is a fairly small program, consisting of main, a couple of small
(inline assembly) routines, and a Timer1 OC interrupt (in C). I will
try to make my description as concise as possible.  We got around the
original problem (i.e. the filtering itself) by making _every_ variable
in main (about 100 bytes or so, total) static, thus taking them off of
the software stack.   This suggested one of a couple of things:  a bad
sector or two in upper RAM, or a memory setup problem.  Well, I raped a
very simple memory test routine (write, read, complement, repeat) from
another project that apparently runs fine on a Mega16, made it a single
function program, i.e. main( ), compiled it in the ICC IDE, then tried
to load it an run it.

It is a stand-alone, non bootloader, type program.  To start, we tried
it on the same prototype board we had been working on. A reset sends to
a seemingly random starting point in the code (although actually one of
several distinct locations), using the recommended C startup file
crtatmega.o.  An AVR Studio soft reset often performs more like a
single-step, sometimes sends it to one of those same "random"
locations, and sometimes sends it off into the weeds.

In an attempt to make some sense of things, I got my hands on an old
board with a different end usage, but also built around the Mega16, and
it performed identically.  I have tried every combination of fuse bits
that makes any sense whatsoever, we use no lock bits, and I am just
really at a loss.

Anyone know of any weirdness between the Mega16 and these tools, or
have any other ideas?

Thanks,
Clark

clark scrobe on the papyrus:

> Greetings all, > > In trying to assist an associate with problems developing code for an > RF comb filter board designed around a Mega16, things are, well, > actting really weird, to say the least. It almost seems to be a > development tool problem, but I am really baffled. I am using ICCAVR > (6.28C), AVR Studio (4.11, build 10, SP3), and a JTAGICE mk II > emulator. > > This is a fairly small program, consisting of main, a couple of small > (inline assembly) routines, and a Timer1 OC interrupt (in C). I will > try to make my description as concise as possible. We got around the > original problem (i.e. the filtering itself) by making every variable > in main (about 100 bytes or so, total) static, thus taking them off of > the software stack. This suggested one of a couple of things: a bad > sector or two in upper RAM, or a memory setup problem. Well, I raped > a very simple memory test routine (write, read, complement, repeat) > from another project that apparently runs fine on a Mega16, made it a > single function program, i.e. main( ), compiled it in the ICC IDE, > then tried to load it an run it. > > It is a stand-alone, non bootloader, type program. To start, we tried > it on the same prototype board we had been working on. A reset sends > to a seemingly random starting point in the code (although actually > one of several distinct locations), using the recommended C startup > file crtatmega.o. An AVR Studio soft reset often performs more like a > single-step, sometimes sends it to one of those same "random" > locations, and sometimes sends it off into the weeds. > > In an attempt to make some sense of things, I got my hands on an old > board with a different end usage, but also built around the Mega16, > and it performed identically. I have tried every combination of fuse > bits that makes any sense whatsoever, we use no lock bits, and I am > just really at a loss. > > Anyone know of any weirdness between the Mega16 and these tools, or > have any other ideas? > > Thanks, > Clark
It sounds like an uninitialised interrupt jump table entry. You probably have a floating pin on INT0 or INT1 and the jump table entry is taking the code to unpredictable locations. The behaviour of Studio is strange, as that is usually quite stable. I suggest you go here: http://www.imagecraft.com/software/ and join the ICCAVR mailing list. There are a lot of helpful people there. You will need to share some code so that the problem can be traced. -- John B
You might try winding out the Software Stack size in Project\Options in
the Imagecraft IDE.

Cheers
TW

Check that you've got Imagecraft and AVR Studio set up for a Mega16 -
if you've got the wrong device set up Imagecraft may generate the wrong
(or right for the device you've set up) interrupt vectors.


TW


Memfault Beyond the Launch