Hi,
I am using an audio module for 3d sound effects where I will be using around 20 pair(for Left and Right Channels) of coefficient buffers of size 200. I could able to run this code on M7 and got expected effects from the module. If I increase my coefficient buffers to 40 pairs of size 200, I am not able to get the expected effects from the module. But I am surprised to get the expected effects when i placed my code in debug mode. I feel there might some memory corruption in increasing the number of buffers. Can somebody help me to sort out this problem. In brief, I am getting different effects when I placed my code in release & debug mode.
Thanks in advance.
regards,
jaikanth.
Hi jaikanth,
What do you mean by "placed my code in debug mode"? Do you mean attaching a debugger, or just compiling it with less optimization/more debug information?
One of the effects you're seeing - increasing the number of buffers - could be a caching effect.Once you increase past the size of the data cache you're essentially provoking more cache activity, and you may simply be seeing the effect because of that increased activity. Producing "debug" binaries which are larger and less efficient may be changing the performance profile of the code and increasing the number of memory accesses, causing a similar churn on the data cache.
How big in bytes is "20 pairs of coefficient buffers of size 200" - are they padded in any way, or is it literally 2*20*200=8000 bytes? How big is the data cache on your Cortex-M7 (perhaps 8KiB?) and what is your system environment like ('operating system' or other software)? Do you have an idea on what kind of explicit cache maintenance is being performed and the MPU settings for the region covering the buffers?
Ta,
Matt
If you are providing your own linker map for laying out memory, you may also find that increasing the number of buffers may just cause different memory resources to start overlapping if they are not spaced far enough apart (e.g. one of ZI, heap, and stack intersect).
The linker *may* error if it can spot this, but it isn't always possible if the resources are not static (E.g. allocated on the stack dynamically, and not guard page at the bottom of the stack). Compiling for debug at a lower optimization level will change the compiler's stacking behavior, which may cause bugs to vanish (or appear).
Also note with the M7 that the cacheability of memory regions may be different, and is controlled by the MPU configuration. If your code is relying on uncached data memory (e.g. to talk to an audio peripheral), but has grown into a cached region due to the increased size, then that may also cause problems. Debuggers often insert cache maintenance to force coherency with the JTAG view of the world automatically, so this is definitely one area where attaching a debugger can make issues disappear.
Cheers, Pete