Altera Forum






Threads: 18,959
Posts: 77,484
Members: 29,244
Welcome to our newest member, pearl87
User
Reputation
9135
7620
5891
4150
3030
2197
2056
1706
1388
1300




 
Register
Quick Search
 
  Altera Forums > IP and Dev Kit Related > Nios Forum > General Discussion > General Discussion Forum

Cancel DMA operation.

Reply
 
Thread Tools Display Modes
  #1  
Old February 6th, 2006, 01:11 AM
Major Major is offline
Altera Scholar
 
Join Date: Jun 2004
Posts: 21
Rep Power: 2277
Major is on a distinguished road
Default

How to cancel DMA operation for alt_dma_rx_chan?
DMA sequence:
1. alt_dma_rxchan_open
2. alt_dma_rxchan_ioctl ( ALT_DMA_SET_MODE_32 )
3. alt_dma_rxchan_ioctl ( ALT_DMA_RX_ONLY_ON )
4. alt_dma_rxchan_prepare
5. wait completion with a time-out

For example: stream device is UART.
If data have not been sent (by host to nios based system) during the time-out interval then time-out occured.

How correctly to do "Cancel" operation for DMA channel?
If programm simple call the alt_dma_close function then a next step sequence 1-5 will be failed.
Reply With Quote
  #2  
Old December 1st, 2009, 05:47 AM
wenhuawu wenhuawu is offline
Altera Pupil
 
Join Date: Nov 2009
Posts: 11
Rep Power: 291
wenhuawu is on a distinguished road
Default Re: Cancel DMA operation.

I've met a problem associats with DMA, i want to receive data from UART through DMA, and store the data into a buffer in on_chipram.
As the handbook says, the alt_dma_rxchan_ioctl() function must been called correctly before can receive data. downside is my program, i don't know is it proper to call the function in that way, at least it doesn't work!
Quote:
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include "sys/alt_dma.h"
#include "alt_types.h"
#include <system.h>
/* flag used to indicate the transaction is complete */
volatile int dma_complete = 0;
/* function that is called when the transaction completes */
void dma_done (void* handle, void* data)
{
dma_complete = 1;
}
int main (void)
{
alt_u8 buffer[32];
alt_dma_rxchan rx;
FILE *fp;
fp=fopen("dev/uart","r");
/* Obtain a handle for the device */
if ((rx = alt_dma_rxchan_open ("/dev/dma")) == NULL)
{
printf ("Error: failed to open device\n");
exit (1);
}
else
{
/* Post the receive request */
if (alt_dma_rxchan_ioctl(rx,ALT_DMA_RX_ONLY_ON ,NULL)<0)
printf("error set\n");
if (alt_dma_rxchan_prepare (rx, buffer, 32, dma_done, NULL) < 0)
{
printf ("Error: failed to post receive request\n");
exit (1);
}
/* Wait for the transaction to complete */
while (!dma_complete);
printf ("Transaction complete\n");
alt_dma_rxchan_close (rx);
}
return 0;
}
Attached Files
File Type: txt DMA.txt (1,013 Bytes, 3 views)
__________________
science makes life simpler
To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts.
Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
USB device mode operation. halfdome Linux Forum 6 December 19th, 2009 02:17 AM
PCI with SGDMA operation newfrance IP Discussion 2 November 10th, 2008 11:30 PM
CF operation icesword General Software Forum 1 October 12th, 2005 03:49 PM
How do I cancel uClinux user login ? supercjb Linux Forum 5 August 12th, 2005 10:09 PM
How to cancel the login? zrycq General Software Forum 4 November 10th, 2004 10:08 AM


All times are GMT -8. The time now is 09:19 PM.