Hi,
It's first time I contact S08AW32 w/ codewarrior 10.6. The development tool is Multilink Universal. I create several files and many function calls.
In file Main.c:
void main(void)
{
Record_AddUser();
}
In file Record.c:
typedef struct {
byte Template[498];
// other members
} tUserData;
void Record_AddUser(void)
{
tUserData sUserData;
// do something...
GetTemplate(gbyTemplate);
memcpy(sUserData.Template, gbyTemplate, 498); // <------ overlapping !!!!
}
In file FP.c: (provided by h/w module vendor)
byte gbyTemplate[498]; // global variable
void GetTemplate(byte* pBuf)
{
byte Buf[498];
// do somethins to get Template, and put it into Buf.
memcpy(pBuf, Buf, 498);
}
After calling function GetTemplate(gbyTemplate), value of many other variables are changed. And then, I find something wrong. The structure sUserData is allocated at 0x0133, and gbyTemplate is allocated at 0x00A5. Can anyone help? Thank you!!
解決済! 解決策の投稿を見る。
Hi,
function scope non-static variables are allocated on stack. Default stack size in CW generated S08 projects is about 0x80 bytes. This is much less than your Buf size plus sUserData size. Stack size is specified in linker *.prm file. Don't forget though that you have only 2k of RAM for all purposes.
Edward
Hi,
function scope non-static variables are allocated on stack. Default stack size in CW generated S08 projects is about 0x80 bytes. This is much less than your Buf size plus sUserData size. Stack size is specified in linker *.prm file. Don't forget though that you have only 2k of RAM for all purposes.
Edward
Hi Edward,
Thank you for reply soon.
Yesterday I had reallocated the stack size several times, but unfortunatelly , nothing changes. The library from module vendor is dedicated for Kinetis. Maybe I'll look for another mcu since I shouldn't modify the library for some reason. In fact, I have these code work fine in Kinetis M0+ and M4 w/ "large" RAM size.
Anyway, you are right. Thx angin!!