Global array memory allocation problems

General discussion on mikroC.
Post Reply
Author
Message
gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

Global array memory allocation problems

#1 Post by gambrose » 23 May 2005 23:15

i have a global array

Code: Select all

char TSIP_Buffer[40];
and a global pointer to this array

Code: Select all

char * Start_TSIP_Buffer = &TSIP_Buffer;
but as i don't reference this array directly it isn't mapped to memory by the memory manger thing.
and so Start_TSIP_Buffer = 0x02 (the PCL reg which causes funny things to happen).

I can add a dummy reference to TSIP_Buffer in the main routine

Code: Select all

TSIP_Buffer[0] = 0;
and this will insure that memory is allocated for the array but Start_TSIP_Buffer still points to PCL!
Graham Ambrose

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#2 Post by gambrose » 23 May 2005 23:19

if i put

Code: Select all

Start_TSIP_Buffer = &TSIP_Buffer;
in main then it will work
so problem seems to be global variable values being assigned before memory has been mapped.
Graham Ambrose

Post Reply

Return to “mikroC General”