NIOS-II+LAN91C111

Hi,everyone,I am now doing a work about ALTERA nios-II.The FPGA I use is cycII-60,and the cpu is NIOS-II f,sdram ,lan91c11,dma controller and so on,the main work I should do is to conmunicate the PCs and nios- II with lan91c111,I chose UDP to send and receive data,also It can work properly if I do'nt use dma to send and receive data,but the speed is low about 18Mbps,cpu freq is 50MHZ,so I want to use dma ,but It doesn't work ,I have a look at the soruce file ,the dma send function have call the callback function s91_dma_tx_done(),but the PC can't catch the udp packet,can some give me some advice ,I have no idear.Thanks!

Reply to
bjzhangwn
Loading thread data ...

Hi,everyone,I am now doing a work about ALTERA nios-II.The FPGA I use is cycII-60,and the cpu is NIOS-II f,sdram ,lan91c11,dma controller and so on,the main work I should do is to conmunicate the PCs and nios- II with lan91c111,I chose UDP to send and receive data,also It can work properly if I do'nt use dma to send and receive data,but the speed is low about 18Mbps,cpu freq is 50MHZ,so I want to use dma ,but It doesn't work ,I have a look at the soruce file ,the dma send function have call the callback function s91_dma_tx_done(),but the PC can't catch the udp packet,can some give me some advice ,I have no idear.Thanks!

Reply to
bjzhangwn

void s91_senddata(SMSC smsc, unsigned char *data, int len) { u_long base = smsc->regbase; /* device base address */ #if 0 unshort *word; /* even byte pointer */ #endif void s91_dma_tx_done(void *); int rc; int *send_buf =(int*)alt_uncached_malloc(0x800); /* sanity check */ if ((len < 60) || (((int)data) & 0x1)) { dtrap(); }

/* Send status word first. This seems to be just a required * placeholder in the devices memory. It's filled in by the * device upon TX complete. */ IOWR_ALTERA_AVALON_LAN91C111_DATA_HW(base, 0);

/* Followed by the byte count; count includes the 6 control bytes. */ IOWR_ALTERA_AVALON_LAN91C111_DATA_HW(base, (len & ~0x1) + 6);

#if 0 word = (unshort *)data; while (len >= 2) { IOWR_ALTERA_AVALON_LAN91C111_DATA_HW(base, *word); word++; len -= 2; } #else #ifndef ALTERA_DMA_A_TX if (((u_long)data) & 0x02) { IOWR_ALTERA_AVALON_LAN91C111_DATA_HW(base, *(unshort *)data); data += 2; len -= 2; }

while ((len -= 4) >= 0) { IOWR_ALTERA_AVALON_LAN91C111_DATA_WORD(base, *(unsigned int

*)data); data += 4; }

smsc->snd_odd = len + 4; smsc->snd_data = data; s91_dma_tx_done((void *)smsc); #else /* disable 91C111 interrupts until DMA completes */ IOWR_ALTERA_AVALON_LAN91C111_MSK(base, 0);

/* do the odd half-word at the beginning by PIO */ if (((u_long)data) & 0x02) { IOWR_ALTERA_AVALON_LAN91C111_DATA_HW(base, *(unshort *)data); data += 2; len -= 2; } //printf ("Start dma send\n"); printf(" len = %d\n",len & ~0x3); //len = len & ~0x3; if ((rc = alt_dma_txchan_send(dma_tx, (void *)(((u_long)data) & ~0x80000000), len & ~0x3, s91_dma_tx_done, (void *)smsc)) < 0) { printf ("Failed to post transmit request, reason = %i\n", rc); exit (1); } smsc->snd_odd = len & 0x3; smsc->snd_data = data + (len & ~0x3); #endif /* ALTERA_DMA_TX */

#endif }

Hi$B!$(BI think I have find the problem,when the dma done,it don't call the callback function s91_dma_tx_done,and the lan91c111 buffer is not receive the new data,but I don't know why the dma not send the data,and the rc is correct.

Reply to
bjzhangwn

OK so it works with CPU but not DMA. Did you try DMA from SDRAM to SDRAM just to copy a block of data ? Did it work ?

Is the peripheral controller capable of bursts ? Did you configure the FIFO access correctly ?

The callback uses an interrupt so make sure you did not mask out the DMA interrupt, that you connected the DMA controller's interrupt line to where it should go, etc. Stick scope probe on the 91c11's RD,WR,CS pins to check if you got your data out. If this is a new design I strongly recomment LAN9117 or LAN9217, much easier to use and faster.

Reply to
PFC

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.