Hello
I am trying to write data to SD card using DMA on CC3200. I have been using this https://e2e.ti.com/support/wireless_connectivity/simplelink_wifi_cc31xx_cc32xx/f/968/t/394899 forum thread describing DMA reads as reference. I am new to both UDMA and SD so maybe I am missing something obvious.
Basically I have just changed read cmd to CMD_WRITE_MULTI_BLK, RX channel to TX channel and order of buffers.
Write operations seems to complete correctly, but only part of target block is written with data (only last 128 bytes of 512 are written)
So here are my questions:
1) How the udma transfer should be setup for performing writes/multi block writes
2) How many SDHOST_INT_DMAWR interrupts should I get ?
-> is it one DMAWR interrupt for whole transfer or one DMAWR for each group of transfers defined by arbitration size
-> how to setup transfer to actually write multiply blocks (read example also reads just one block with arb size = 1)
3) Do you have any helpfull links/examples that may be usefull when working with UDMA and SDHost
Here is the code I have been using:
static void SDIntDmaWriteHndl() { unsigned long ulStatus; ulStatus = SDHostIntStatus(SDHOST_BASE); SDHostIntClear(SDHOST_BASE, 0xffffffff); if (ulStatus & SDHOST_INT_DMAWR) { g_ucSDUdmaWriteCompleted++; } } unsigned long SDDmaWriteTest() { unsigned long ulItemsCount = 0; unsigned long ulBlockNo = 0; SDHostIntRegister(SDHOST_BASE, SDIntDmaWriteHndl); SDHostIntDisable(SDHOST_BASE, 0xFFFFFFFF); SDHostIntEnable(SDHOST_BASE, SDHOST_INT_DMAWR); if(g_sdCard.ulCapClass == CARD_CAP_CLASS_SDSC) { ulBlockNo = ulBlockNo * 512; } memset(g_ucSdBuffer, 'a', SD_BLOCK_SIZE); SDHostBlockSizeSet(SDHOST_BASE, SD_BLOCK_SIZE); SDHostBlockCountSet(SDHOST_BASE, 1); SDHostIntClear(SDHOST_BASE,0xFFFFFFFF); ulItemsCount = SD_BLOCK_SIZE/4; UDMASetupTransfer(UDMA_CH24_SDHOST_TX, UDMA_MODE_BASIC, ulItemsCount, UDMA_SIZE_32, UDMA_ARB_1, (void *) g_ucSdBuffer, UDMA_SIZE_32, (void *)(SDHOST_BASE + MMCHS_O_DATA), UDMA_DST_INC_NONE ); g_ucSDUdmaWriteCompleted = 0; if (SDHostCmdSend(SDHOST_BASE, CMD_WRITE_MULTI_BLK|SDHOST_DMA_EN, ulBlockNo) != 0) { Report("[SDDmaWrite] SDHostCmdSend failed \n\r"); return 1; } while (g_ucSDUdmaWriteCompleted == 0) { } SDHostCmdSend(SDHOST_BASE, CMD_STOP_TRANS, 0); return 0; }
After reading data from block 0, I am gettin following
0000 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0014 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0028 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
003c :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0050 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0064 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0078 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
008c :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00a0 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00b4 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00c8 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00dc :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00f0 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0104 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0118 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
012c :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0140 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0154 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0168 :00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
017c :00 00 00 00 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
0190 :61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
01a4 :61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
01b8 :61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
01cc :61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
01e0 :61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
01f4 :61 61 61 61 61 61 61 61 61 61 61 61
Thanks in advance,
Andrzej