WIZnet Developer Forum

Read W5200 regs using SPI DMA

Hi All,

I am able to read (W5200 registers) SHAR / SIPR / GAR one by one using a laborious DMA setup. I want to simplify this and read/write all the common registers once for all.

Here is the code i am using to write/read SHAR register from a CC3200 Master device.

static uint8_t tx_buffer[DMA_SIZE];
static uint8_t rx_buffer[DMA_SIZE];
#define DMA_SIZE 10

uint8_t send_mac[10] = {0x00,0x09,0x80,0x14,0xFE,0xA8,0xD9,0xC0,0x18,0xF3};
uint8_t recv_mac[10] = {0x00,0x09,0x00,0x14,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};

/* Setting the MAC Address through SPI DMA operation */

memcpy(tx_buffer,send_mac,sizeof(send_mac)); // Fill buffer with MAC address and W5200 Write Protocol Values
UDMASetupTransfer(UDMA_CH31_GSPI_TX,UDMA_MODE_BASIC,DMA_SIZE,
UDMA_SIZE_8,UDMA_ARB_1,
tx_buffer,UDMA_SRC_INC_8,
(void *)(GSPI_BASE + MCSPI_O_TX0),UDMA_DST_INC_NONE); // Setup DMA

SPICSEnable(GSPI_BASE); // Start transfer

while(transfer_status != COMPLETE) // Wait for transfer to complete
{
if (uDMAChannelModeGet (UDMA_CH31_GSPI_TX | UDMA_PRI_SELECT) == UDMA_MODE_STOP)
txdone = 1;
if (txdone)
{
SPICSDisable(GSPI_BASE);
transfer_status = COMPLETE;
}
}

/* Getting the MAC Address through SPI DMA operation */
memset(tx_buffer,0xFF,sizeof(tx_buffer)); // Fill buffer with Dummy Writes (0xFF)
memcpy(tx_buffer,recv_mac,sizeof(recv_mac)); // Fill buffer with W5200 Read Protocol Values

UDMASetupTransfer(UDMA_CH31_GSPI_TX,UDMA_MODE_BASIC,DMA_SIZE, //5byte command
UDMA_SIZE_8,UDMA_ARB_1,
tx,UDMA_SRC_INC_8,
(void *)(GSPI_BASE + MCSPI_O_TX0),UDMA_DST_INC_NONE);

UDMASetupTransfer(UDMA_CH30_GSPI_RX,UDMA_MODE_BASIC,DMA_SIZE, //only 6 bytes!
UDMA_SIZE_8,UDMA_ARB_1,
(void *)(GSPI_BASE + MCSPI_O_RX0),UDMA_SRC_INC_NONE,
rx,UDMA_DST_INC_8);

SPICSEnable(GSPI_BASE);

For reading the common registers, I just change to 0x36 for the Write and Read protocol Length Values and DMA_SIZE macro.

But I do get all Zeros if I read anything in bulk. What setting am I missing? Please help.

Thanks much,
Soumya

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.