Hi,
I have the following function in the PRU to initialize a two-dimensional array (pointers into that array get passed back to a Linux program). The function was purposely made verbose to avoid confusion, yet the compiler seems confused anyway. All optimizations are turned off.
/* Clear all position arrays to zero */
void clearBuffer()
{
int i, j, k=50;
for ( i=0 ; i<RING_SIZ ; i++ )
{
for ( j=0 ; j<MAX_NODES ; j++ )
{
positions[i][j] = k*10;
k = k+1;
}
}
}
Now you would expect this code to generate the sequence 500, 510, 520, 530, 540, . . . 950, 960, 970
But instead, it generates the following sequence:
500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547,
It appears to me that the compiler is doing the multiply k*10 only once, and then incrementing from there, rather than multiplying after each increment. This is a serious issue for me, as I need to do a lot of scaling in the PRU.
Thanks for any help.
Mark