global data

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

global data

932件の閲覧回数
bones
Contributor I

I am using the MC9S12Xeq512 processor as a new user. I had a problem when a c file had a global variable of type struct is declared. The program built ok using Cosmic but the app did not run. I changed the global to static const and all was well. The funny thing is that the global was only used by functions inside the file. Any ideas for this behavior. With this paged memory, are there rules of thumb for treating global and file scope variables?

 

Thanks,

David 

ラベル(1)
0 件の賞賛
返信
1 返信

766件の閲覧回数
Lundin
Senior Contributor IV

I don't know Cosmic, but it seems that the problem could be related to static initialization. If you declare a variable as const it will likely end up in flash, and if ou don't declare it as const, it will likely end up in RAM. And then, if you pick a minimal non-standard startup code as is custom with most embedded compilers, the variable won't be initialized and contain garbage values.

0 件の賞賛
返信