help array size

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

help array size

3,237 Views
Wind
Contributor I
hi,
 
I am trying to store the message from the keypress in an array of size 500. when I compile, the memory location of the array kyprs_buf[500] and keyRo are in the reserve area.  Program can still run but will stop at the declaration of kyprs_buf[500]. I tried before declaring this array[500] at one of the sample software by freescale and it works. I don't know what happen here.
 
2. there are warning saying that
 
Warning : C1420: Result of function-call is ignored
key.c line 68  
 
this happens when calling the function 
 
dosomething()    
 
 
Labels (1)
0 Kudos
8 Replies

808 Views
CrasyCat
Specialist III

Hello

I noticed you have define kyprs_buf[500] locally in a function. That means that it will be allocated on the stack. 

How big is your stack? Make sure it is big enough.

CrasyCat

0 Kudos

808 Views
Wind
Contributor I

hi cat,

thanks for pointing out it is a stack problem. initially I thought I have enough 8K RAM to store all the info.

I am using MC9S12NE64 in my embedded web  project ( ANSW2836SW open TCPIP stack)  and I created the  array[500] in the function to store the info from browser. it works.

I started a new project file to test the keypad code and later I will copy the firmware to the original embedded web project file.

I had search through the data sheet of MC9S12NE64 and read the app note AN1064 (title: using the M68HC11 stack) but I still can't find how to solve this problem.

 

1. how to create an array with the size of array[500]?

 2.how to find out the size of the stack

3. where is the address of stack?

4. any app note or documents that I can read further?

 

 

Message Edited by Wind on 2006-07-18 07:19 PM

0 Kudos

808 Views
CrasyCat
Specialist III
Hello
 
Actually the array is defined appropriately. It is just that you have to reserve enough space for the stack if you want to define it as a local variable.
 
To check the current location (and size) of the stack just edit the .map file generated bay the linker.  The section .stack is where the stack will be defined.
If you want to define a bigger stack, edit the file *.prm and change the line
     STACKSIZE 0x100
 
Adjust the stack size and define a bigger stack (0x500 for example).
 
Otherwise you can define the table as a global or static local variable. This way the variable will not be allocated on the stack but in RAM.
 
Anyway I have some trouble to understand what you are trying to do in key_rotate function. As keyprs_buf is defined as local variable, its content is not persistent over function call (i.e. is content gets undefined each time you enter the function again).
So actually the parameter you pass there will be lost again at the end of the function. Is that really what you are looking for?
 
CrasyCat
0 Kudos

808 Views
Wind
Contributor I

hi cat,

I have move the kyprs_buf [500] to global. it works fine. thanks. 

I look into  the map file and .prm file of ANSW2836SW

in .prm file

STACKTOP 0x3FFF

in the map file

                                    size  type       from           to            segment

.stack                             1    R/W     0x3FFF     0x3FFF   .stackSeg

the stack size is only 1 x 16 bits

what does this STACKTOP means?

if the stack size is only 16 bits, how to push the stack?

 

0 Kudos

808 Views
CrasyCat
Specialist III
Hello
 
STACKTOP defines the initial value for the stack pointer only. It does not define a size.
To determine what is the available size for the stack check the section
"OBJECT LIST SORTED BY ADDRESS" and find out what is the address of the last global object before 0x3FFF.
 
Interval between that object & 0x3FFF is the space available for the stack.
 
Please refer to the manual {Install}\Help\PDF\Build_Tools_Utilities.pdf Chapter "Smart Linker" for more information on linker commands.
Section "SmartLinker Commands" describes all these commands.
 
CrasyCat
0 Kudos

808 Views
Wind
Contributor I
hi,
 
forgot to mention: the warning message is still exist
 
Warning : C1420: Result of function-call is ignored
key.c line 68  
 
any idea about this?
0 Kudos

808 Views
CrasyCat
Specialist III
Hello
 
This message is generated when a function is declared with a return value and you do not assign the return value to a variable when you called the function.
 
Extract from on line help for that message
"A function call was done without saving the result.Example
int f(void);void main(void) {  f(); // ignore result}
Assign the function call to a variable, if you need the result afterwards. Otherwise cast the result to void. E.g.:
int f(void);void main(void) {  (void)f(); // explicitly ignore result}
"
CrasyCat
0 Kudos

808 Views
Wind
Contributor I

hi cat,

thanks for the info. I had downloaded the file and I will slowly read up the build tool utilities manual.

0 Kudos