from CF-Card I read 4 bytes which determine the length of a file. These 4 bytes are added together to a long-variable for further calculating the sectors on the CF-card.
Code: Select all
filesize = filesize + Cf_Read_Byte();
filesize = filesize + (Cf_Read_Byte() << 8);
filesize = filesize + (Cf_Read_Byte() << 16);
filesize = filesize + (Cf_Read_Byte() << 24);
usart_sendlong(filesize);
Received: 0x20 0x20 0x20 0x20 0x20 0x20 0x32 0x36 0x34 0x39 0x39
When I replace the CF_Read_Byte() with the values from the CF-Card, I get the correct value for the filesize :
Code: Select all
filesize = filesize + 0x35;
filesize = filesize + (0x06 << 8);
filesize = filesize + (0x40 << 16);
filesize = filesize + (0x00 << 24);
usart_sendlong(filesize);
Received: 0x20 0x20 0x20 0x20 0x34 0x31 0x39 0x35 0x38 0x39 0x33
This is the code of the usart_sendlong:
Code: Select all
void Usart_SendLong(long NumToSend)
{
char * text;
LongToStr(NumToSend,text);
while(*text){
USART_Write(*text++);
}
}