Forum Discussion
Altera_Forum
Honored Contributor
15 years agoCode for the first transaction (which works fine.)
/******************************************************************
* Copy 0 to 1/3th of DDR2 memory to 1/3 to 2/3th of memory *
******************************************************************/
void dma_driver_0_33 ()
{
int i;
int rc; //request
alt_dma_txchan txchan;
alt_dma_rxchan rxchan;
void* tx_data = (void*)ALTMEMDDR_1_BASE; /* pointer to data to send */
void* rx_buffer = (void*)(ALTMEMDDR_1_BASE+0x1500004); /* 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 ("First 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));
}
//printf("Content of DDR2 SDRAM(offset 0x1500004):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));
}
}