AnsweredAssumed Answered

9S12X RAM data unreadable after function call

Question asked by Olivier LE ROY on Jun 21, 2013
Latest reply on Jun 24, 2013 by Olivier LE ROY

Hello,

 

I use the 9S12XEQ384 derivative. My compiling options are: -CPUHCS12XE -D__NO_FLOAT__ -D__MAP_FLASH__ -D__FAR_DATA -Mb -MapFlash -Onf -OnB=b -PSegObj

 

I first set an array of 8 bytes of data in func1.

Then I call func2 with a pointer to this array of 8 bytes as argument.

Inside func2, all data read from this array are 0s,I don't understand this.

 

I.e. the following program:

 

void func1_every1ms(void)

{

   U8 buffer[8] = {0, 0, 0, 0, 0, 0x0A, 0x0F, 0x05};

 

   log_printf("Inside func1, before call:\n");

   log_U32((U32)buffer);

   log_U32(*(U32 *)&buffer[0]);

   log_U32(*(U32 *)&buffer[4]);

 

   func2_handler(buffer);

 

   log_printf("Inside func1, after call:\n");

   log_U32(*(U32 *)&buffer[0]);

   log_U32(*(U32 *)&buffer[4]);

}

 

void func2_handler(U8 *buffer)

{

   if (buffer != NULL))

   {

   log_printf("Inside func2:\n");

   log_U32((U32)buffer));

   log_U32(*(U32 *)&buffer[0]);

   log_U32(*(U32 *)&buffer[4]);

   }

 

gives the following result:


Inside func1, before call

01B9C00

00000000

00000AF5

Inside func2:

01B9C00

00000000

00000000

Inside func1, after call

00000000

00000AF5


Does anyone have an idea why it is not possible to read back the 8 byte array of data inside func2, and why instead I read all zeros?

Outcomes