Hello,
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; SDC_vReadDataBlock(&Copy_PsSdcard->SD_CARD_CONNECTION,Copy_PsFileSystemInfo->FIRST_FAT_SECTOR+Base,(u8*)Buffer); Copy=Buffer[Offset]; 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
Got indices into Buffer going up to 511 rather than limited to 127
thanks for your helpful response. All questions answered
png to ico