This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC2400 Erratic code execution

Hi

Recently my ARM LPC2478 MDK-ARM project has reached a point where if I add one extra line of code I see all kinds of RAM corruption and sometimes the DABT_handler being called. If I remove that line of code everything is all OK again. The corruption is noticable as text on a LCD corrupting between frame updates even though it is just being copied from Flash to external RAM.

The extra line of code can be totally irrelevant, for example adding a line to draw a bitmap to an LCD can cause erractic code behaviour even if that line of code never gets executed.

Right now I can only get it to work and execute correctly with level -O3 optimisation, any level below that is now causing problems. My on board 512K flash is pretty full up but I have moved some bitmap files into an external Flash but the problem is still the same.

I am using about 4Mbytes of DDR external RAM out of 32Mbytes total. I have tried doubling the stack and heaps but still the same problem. I also tried reducing the overall external RAM bandwidth but still the same problem.

Does anyone know if there are limits on say the individual C module lengths? I saw a very similar problem a few days back when I tried using sprintf function with %f. Could this be due to a larger library being linked and also taking the code over some limit which I have again reached?

Could this be a compiler error? For information I am using a lot of C modules with unbounded arrays to hold bitmaps, fonts and sound effect. Could this be part of the problem?

I would appreciate any suggestions you can think of as this problem has totally stopped development.

Thanks in advance.

  • Have you check your stack spaces for overflow?

    Bradford

  • Hi

    I don't think it is a stack problem as I have doubled them and doubled them again whilst trying to solve this problem. The problem comes and goes depending on adding a few lines of irrelevent code elsewhere.

    One thing I should mention is I see wide string (wchar_t) corruption whilst drawing to an LCD but only on certain frame updates. Therefore it appears the original storage of the strings is still OK but its getting corrupted during wcscpy or swprintf.

    Is wchar.h and wctype.h known to have any problems?

    Another thing I'm looking at is the memory accelerator module. I am using the same settings as the Blinky example and same external RAM as a MCB2400 eval board. The MAM timing=4 if I use a lower number of 1 or 2 it doesn't work, perhaps a setting of 4 is marginal and I need to increase this number?

  • If it isn't stack space, then it's often uninitialized variables (specially pointers) or buffer overflows from accessing arrays with negative index or too high index.

    Or having interrupts interact with main code with concurrent modification of critical variables.