Hi, I'm compiling a program in MPLAB C32 and I have a very odd thing going on. The compiler seems to be swaping the order of the parameters passed to a function. Here is the code (simplified. It is being simulated on MPLAB SIM): The idea was to make a circular buffer. void main(void) { do{ for( i = 0; i < 100; i++ ) { LoadToBufferCirc( (signed long*)Channel2Bfr, 1, 100 ); } for( i = 0; i < 100; i++ ) { longtemp3 = GetFromBuffer( (signed long*)Channel2Bfr, (unsigned char)i, (unsigned char)BufferCh2Len ); } }while(1); } The functions are: void LoadToBufferCirc( signed long* ChannelBfr, signed long Data, unsigned char BufferLen ) { signed long Pointer; Pointer = ChannelBfr[0]; Pointer++; if( Pointer >= BufferLen ) Pointer = 0x01; ChannelBfr[Pointer] = Data; ChannelBfr[0] = Pointer; } signed long GetFromBuffer( signed long* ChannelBfr, unsigned char PosBuffer, unsigned char LenBuffer ) { signed long Pointer; if( PosBuffer >= LenBuffer ) return; Pointer = ChannelBfr[0]; // Load the current end pointer Pointer++; // The oldes data is right next to the Last Pointer Pointer += PosBuffer; // Load the offset if( Pointer >= LenBuffer ) { Pointer = Pointer - LenBuffer; // Pointer; } return ChannelBfr[Pointer]; } The problem is that in LoadToBufferCirc(), LenBuffer is 1 and Data is 100, wich is the opposite of what I'm sending from main(). Anyone seen this before? Is a bug or I can't see an error in my code? Regards, Mauricio -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist