Stack usage (CWS-H12-PRO v. 4.5)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Stack usage (CWS-H12-PRO v. 4.5)

ソリューションへジャンプ
3,489件の閲覧回数
Sten
Contributor IV
Am I missing something, or does not the CW compiler/linker inform you about the stack usage. I am also using a Cosmic compiler for the HC08-family, and it has a very convenient stack usage map in the linker's MAP-file that tells you the total stack needed for all entry points (main() and ISRs), and from that is is easy to define the stack size. I have found the -Ll option in CW and had a look at the generated logfile.txt, but to, from that, manually calculate the total stack usage for a not so small project, would be very difficult.
 
One way to determine the stack usage would of course be to examine the stack content with the debugger after the application has run for a while, but that is not a very scientific way of doing it and does not guarantee that the worst case was found.
 
Any ideas, anybody?
 
Sten
 
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,092件の閲覧回数
CrasyCat
Specialist III

Hello

This is not working in the current version of the tools, but has been recorded as a feature request for future release of the tools.

CrasyCat

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
1,093件の閲覧回数
CrasyCat
Specialist III

Hello

This is not working in the current version of the tools, but has been recorded as a feature request for future release of the tools.

CrasyCat

0 件の賞賛
返信
1,092件の閲覧回数
Technoman64
Contributor III
I tested the following code using the simulator for a HCS12DJ256. Not sure if this is what you are looking for though. Should be able to create a test project and paste this code into main.c
 
#include <hidef.h>      /* common defines and macros */
#include <mc9s12dj256.h>     /* derivative information */

#pragma LINK_INFO DERIVATIVE "mc9s12dj256b"
 
/* Define to turn on stack checking */
#define DEBUG_STACK
 
/* Macro to calculate amount of stack used */
#define STACK_CHECK asm PSHX; asm TSX; asm STX StackPtr; asm PULX;\
  StackUsed = StackStart - StackPtr /*; asm BGND */

/* Macro to save stack start */
#define STACK_START asm PSHX; asm TSX; asm STX StackStart; asm PULX
 
/* Variables for stack checking only asllocated if DEBUG_STACK is defined */
#ifdef DEBUG_STACK
unsigned int StackPtr = 0;
unsigned int StackStart = 0;
unsigned int StackUsed = 0;        
#endif
 
/* Just some variables */
int i;
int Array[100];
 
/* Just a function for testing stack usage */
void Function1(void){
 int Array2[10];
 
 /* If we are stack checking do it here */
 #ifdef DEBUG_STACK
  STACK_CHECK;
 #endif
 
 /* Do something */
 for(i=0; i<10; i++){
  Array[i] = i;
 }
 
 /* Use local array so compiler does not optimize it out */
 Array2[0] = Array[5];
}
 
/* Main function */
void main(void) {
 
   /* Get stack starting position */
 #ifdef DEBUG_STACK
  STACK_START;
 #endif
 
 /* Call test function */
 Function1();
 
 for(;:smileywink: {} /* wait forever */
}
1,092件の閲覧回数
Sten
Contributor IV

Thanks CrasyCat and Technoman,

while waiting for the feature to be included in the tools, I will use the idea with inline stack checking to collect the deepest stack during runtime.

Sten

0 件の賞賛
返信