Is there a way to determine the total stack size available and consumed by the variables in the program?
Same for the memory i.e total available and consumed by the program? It seems there's a stack overflow or the program is accessing something beyond its limit which is resulting in garbage characters in debug print viewer.
You're pointing at an 8051 article, not an ARM one, but there should be a .MAP file generated by the Linker in the output directory along with the .AXF file. It will have the name of you project, ie project.axf, project.map, etc.
The Linker will throw an error if the target memory is exceeded, provided you've supplied a valid value for it in the Target dialog.
For the stack, fill it with a character you recognized, and then put the stack in the memory view of the debugger, and watch the fill character get eaten away. Run the app through it's paces and then look at the high-water mark for how much of the stack has be utilized.
As I recall the Linker also outputs a .HTM file describing call trees and local variable usage. Might be a check box item.
Get some training, find someone in your own organization who can mentor you and working on your debugging and diagnostic skills.
As I add a few more variables in my program, suddenly I get an error ARM: *** error 65: access violation at 0xD1010BC8 : no 'read' permission.
I suspect that's because target memory is exceeded or perhaps stack overflow occurs?!
Didn't quite get by "..fill it with a character you recognized, and then put the stack in the memory view of the debugger, and watch the fill character get eaten away".
You mean fill a character in the stack?
Unfortunately I don't know alot of people who are good with this so I have to learn everything by myself
Look at what code is causing the Error! Work backward from there. Consider bisecting the additional code until you understand exactly which variable pushes you over the edge.
Fill it with something you can recognize. Say it's 0x1000 in size, fill that space with 'C' (0x43), look at it with a viewer, and see the 'C' characters get eroded as the tide of stack usage ebbs in and out of the call trees. Remember how stacks work on this CPU, they descend downward. Stack usage here is 0x1000-0x0374
20000000 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43 CCCCCCCCCCCCCCCC 20000010 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43 CCCCCCCCCCCCCCCC 20000020 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43 CCCCCCCCCCCCCCCC 20000030 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43 CCCCCCCCCCCCCCCC ... 20000350 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43 CCCCCCCCCCCCCCCC 20000360 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43 CCCCCCCCCCCCCCCC 20000370 : 43 43 43 43 FE BD F7 B5 - 16 46 0D 46 00 24 FF F7 CCCC.....F.F.$.. 20000380 : A4 FF 76 4F 38 46 FF F0 - 3B FE 04 28 11 D0 FF F7 ..vO8F..;..(.... 20000390 : 71 FE 0E E0 28 5B C0 43 - 01 04 28 5B 08 43 00 99 q...([.C..([.C.. ... 20000FD0 : 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 20000FE0 : 61 70 68 31 00 00 00 00 - 00 00 00 00 00 00 00 00 aph1............ 20000FF0 : 00 00 00 00 00 00 00 00 - 00 00 11 00 31 00 C0 00 ............1...
If you suspect something, do some testing/analysis to prove or disprove the theory. Look at things you can inspect.