AnsweredAssumed Answered

RSI data is out of order

Question asked by 2sb18 on Dec 16, 2015
Latest reply on Dec 24, 2015 by Nabeel

I'm running a BF514F. Reading a sector from a FAT32 partition on an SD card using RSI. It's working, but as you see in the code below, I have to flip around the data, as it's big endian. Is there a way to get around having to do this? I tried using a word size of 8-bits, but it didn't work. The hardware reference also states that a 32-bit word size should be used. Thanks for any suggestions! Steve.

 

void sd_card_read_sector ( unsigned int sector, unsigned char * destination_address ) {

  * pDMA4_START_ADDR = block;

  * pDMA4_X_COUNT = BLOCK_SIZE;

  * pDMA4_X_MODIFY = 4;

  * pDMA4_CONFIG = DMAEN | WNR | WDSIZE_32;

  * pRSI_ARGUMENT = sector;

  * pRSI_DATA_CONTROL = DATA_EN | DATA_DIR | DATA_DMA_EN | 0x90;

  * pRSI_COMMAND = SD_MMC_CMD_READ_SINGLE_BLOCK | CMD_E;


  while ( ! ( * pRSI_STATUS & DAT_BLK_END ) );

 

  * pRSI_STATUSCL = DAT_BLK_END | DAT_END;

  * pDMA4_IRQ_STATUS &= ~DMA_DONE;

 

  // have to flip the data around

  unsigned int i;

  for ( i = 0; i < 128; i++ ) {

    destination_address[4 * i + 3] = ( block[i] & 0xFF000000 ) >> 24;

    destination_address[4 * i + 2] = ( block[i] & 0x00FF0000 ) >> 16;

    destination_address[4 * i + 1] = ( block[i] & 0x0000FF00 ) >> 8;

    destination_address[4 * i + 0] = ( block[i] & 0x000000FF ) << 0;

  }

}

Outcomes