Error in returning a value


I have a very strange behavior in the below code

u32 Buffer[128];	/*Sector Buffer*/

static u32 ReadFATEntry(SD_CARD_t *Copy_PsSdcard,FS_INFO *Copy_PsFileSystemInfo,u32 Copy_u32ClusterNumber){
	u32 Copy;
	u32 Base=Copy_u32ClusterNumber/512;
	volatile u32 Offset=Copy_u32ClusterNumber%512;
	return Copy;

This function just read a sector from sdcard and save it into a global buffer then it returns a value from this buffer according to offset, the problem is that when i return the value, a zero is returned instead of the value. I turned off the optimizer and interrupts but there is no change, i debugged the code the value is correct in variable "copy" but as soon as i return it, the problem happens and a zero is returned.

thank you

More questions in this forum