Internal Error with arrays on XGATE

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

Internal Error with arrays on XGATE

Jump to solution
1,198 Views
Olitsch
Contributor I

Hi there,

 

i have a ringbuffer in shared data segment so both cpu and XGATE can access it :

 

typedef struct
{    
  unsigned char in;
  unsigned char out;
  unsigned int buffered;
  unsigned int timerOvrFl;
  unsigned char data[256];
 
} rBuffer;

rBuffer ring_buffer;

 In the cpu code the instruction

 

ring_buffer.data[ring_buffer.in];

 

 

 

works fine, but when i try the same on XGATE i get a error popup:

 

Internal Error #601in c:\......\ccpp.cpp while compiling xgate.cxgate, please report to freescale.

 

a workaround is :

 

in=ring_buffer.in;

ring_buffer.data[in];


 

 

but since timing is critical i cant afford the extra operation.

 

I´m using version 4.5 and a 9S12XDP512

 

Does anyone know a solution?

Labels (1)
Tags (1)
0 Kudos
1 Solution
554 Views
kef
Specialist I

XGATE compiler from CW for S12(X) V5 with 5.01 patch seems being fine with this

 

char cc;

 

 ring_buffer.data[ring_buffer.in] = cc;

 

or

 

 cc =  ring_buffer.data[ring_buffer.in];

 

 

 

If upgrading is not an option for now, then try playing with compiler settings. Disabling all or some optimizations may help.

 

You say

  • but since timing is critical i cant afford the extra operation.

 

At least latest XGATE compiler is able to keep local variables in registers and eliminate some intermediate operations.

 

If you are worrying about timing, then you should reference your data (data structure) via pointer that could be passed as a XGATE thread argument, which is passed in R1 register. I mean doing it the same like it is done in CW wizard generated project, see how MyData struct is passed to SoftwareTrigger0_Handler().  In your case if would like as this

 

1) data structure is passed in R1 register to XGATE

 

interrupt void thr(rBuffer * __restrict rb) {

   cc = rb->data[rb->in];
}

 

2) R1 register is initialized in XGATE vector table like this:

 

  {ErrorHandler, 0x36},  // Channel 36 - XGATE Software Trigger 3          
  {ErrorHandler, 0x37},  // Channel 37 - XGATE Software Trigger 2          

.....
  {(XGATE_Function)thr, (int)&ring_buffer},   // <----- pointer to ring_buffer will be loaded to R1 before thr thread call

 

 

 

View solution in original post

0 Kudos
3 Replies
555 Views
kef
Specialist I

XGATE compiler from CW for S12(X) V5 with 5.01 patch seems being fine with this

 

char cc;

 

 ring_buffer.data[ring_buffer.in] = cc;

 

or

 

 cc =  ring_buffer.data[ring_buffer.in];

 

 

 

If upgrading is not an option for now, then try playing with compiler settings. Disabling all or some optimizations may help.

 

You say

  • but since timing is critical i cant afford the extra operation.

 

At least latest XGATE compiler is able to keep local variables in registers and eliminate some intermediate operations.

 

If you are worrying about timing, then you should reference your data (data structure) via pointer that could be passed as a XGATE thread argument, which is passed in R1 register. I mean doing it the same like it is done in CW wizard generated project, see how MyData struct is passed to SoftwareTrigger0_Handler().  In your case if would like as this

 

1) data structure is passed in R1 register to XGATE

 

interrupt void thr(rBuffer * __restrict rb) {

   cc = rb->data[rb->in];
}

 

2) R1 register is initialized in XGATE vector table like this:

 

  {ErrorHandler, 0x36},  // Channel 36 - XGATE Software Trigger 3          
  {ErrorHandler, 0x37},  // Channel 37 - XGATE Software Trigger 2          

.....
  {(XGATE_Function)thr, (int)&ring_buffer},   // <----- pointer to ring_buffer will be loaded to R1 before thr thread call

 

 

 

0 Kudos
554 Views
Olitsch
Contributor I

The error didnt go away, but i changed the code like you suggested with a pointer to the structure. So my code works fine and it´s even a bit faster :smileyhappy:

 

thanks alot

0 Kudos
554 Views
CompilerGuru
NXP Employee
NXP Employee

Did you try the 5.0? If this bug may still be in the latest version, it would be helpful if you file a service request so

FSL can make sure it gets fixed. Otherwise sooner or later others way stumble across it, for sure.

 

Daniel

0 Kudos