Forum Discussion
Altera_Forum
Honored Contributor
17 years agomy DMA controller doesn't works
I'm trying to integrate my custom hardware DSP blocks in my system using Cyclone III NIOSII evaluation kit (EP3C25). But I'm having some troubles by using DMA controllers for sending and receiving da...
Altera_Forum
Honored Contributor
17 years agoHi Jack thanks for your correction, I've change the name in both DMA channels according with <system.h> and DMA Channels are free of errors when opening
Now I've tried to send and receive through the Tx & Rx DMA channels using this,
/* flag used to indicate the transaction is complete */
static volatile int rx_done = 0;
// Callback function that obtains notification that the data has
static void done (void* handle, void* data){
rx_done++;
}
alt_u8 img_buffer;
in main():
printf ("starting data transfer...\n");
/* Post the transmit request */
if ((rc = alt_dma_txchan_send (txchan,img_buffer,128,NULL,NULL)) < 0){
//if ((rc = alt_dma_txchan_ioctl(txchan,ALT_DMA_TX_ONLY_ON,img_buffer)) < 0
printf ("Failed to post transmit request, reason = %i\n", rc);
}
/* Post the receive request */
if ((rc = alt_dma_rxchan_prepare (rxchan,img_buffer,128,done,NULL)) < 0){
//if ((rc = alt_dma_rxchan_ioctl(rxchan,ALT_DMA_RX_ONLY_ON,img_buffer)) < 0){
printf ("Failed to post read request, reason = %i\n", rc);
}
/* wait for transfer to complete */
while (!rx_done);
OSTimeDlyHMSM(0,0,1,50);
printf ("Transfer successful!\n");
I've check both alt_dma_txchan_send & alt_dma_txchan_ioctl options, but the program always hangs waiting for DMA done transfer. I don't know when If I use alt_dma_rxchan_ioctl how to specify the number of bytes to be sent/received