Forum Discussion
Altera_Forum
Honored Contributor
15 years agoCode for the second DMA transaction (where something goes wrong.)
But it's the same (apart from the addresses) as the other code:
/******************************************************************
* Copy 1/3 to 2/3th of DDR2 memory to 2/3 to end of memory
******************************************************************/
void dma_driver_33_66 ()
{
int i;
int rc; //request
alt_dma_txchan txchan;
alt_dma_rxchan rxchan;
void* tx_data = (void*)ALTMEMDDR_1_BASE+0x1500004; /* pointer to data to send */
void* rx_buffer = (void*)(ALTMEMDDR_1_BASE+0x3000004); /* pointer to rx buffer */
txrx_done=0;
/* Create the transmit channel */
if ((txchan = alt_dma_txchan_open("/dev/dma_tester")) == NULL)
{
printf ("Failed to open transmit channel\n");
exit (1);
}
/* Create the receive channel */
if ((rxchan = alt_dma_rxchan_open("/dev/dma_tester")) == NULL)
{
printf ("Failed to open receive channel\n");
exit (1);
}
/* Post the transmit request */
if ((rc = alt_dma_txchan_send (txchan,
tx_data,
0x150000,
NULL,
NULL)) < 0)
{
printf ("Failed to post transmit request, reason = %i\n", rc);
exit (1);
}
/* Post the receive request */
if ((rc = alt_dma_rxchan_prepare (rxchan,
rx_buffer,
0x150000,
txrxDone,
NULL)) < 0)
{
printf ("Failed to post read request, reason = %i\n", rc);
exit (1);
}
/* wait for transfer to complete */
while (!txrx_done);
printf ("Second transfer successful!\n");
printf("Content of DDR2 SDRAM after DMA operation\n");
for (i=0x0;i<0x20;i+=4)
{
printf("Address 0x%X: %x\n",i+(int)tx_data,IORD_32DIRECT((int)tx_data,i));
}
//IOWR_32DIRECT(rx_buffer, 0, 0x11);
printf("Content of DDR2 SDRAM after DMA operation\n");
for (i=0x0;i<0x20;i+=4)
{
printf("Address 0x%X: %x\n",i+((int)rx_buffer),IORD_32DIRECT((int)rx_buffer,i));
}
}