--- Quote Start ---
originally posted by major@Sep 7 2004, 10:35 PM
anybody use the dma hal driver?
i need correct example for stream device and memory.
i want receive from steram device through dma(using hal) and save stream data to memory.
i have written worked code using dma registers, but can't get right result for hal.
studying of sourcel codes for hal dma indirectly specifies a mistake in hal library, but i am not confident it. --- Quote End ---
Major.
Have you looked at the example on page 4-21 of the Nios II Software Developer's Handbook, there is an example of exactly what you're trying to do and it works. If this does not answer your question then please post back.
Lastly the bug that Kerri refers to is an edge case, and will not apply in the use case you have described.
To explain the problem, it is important to understand the HAL DMA model. This expects a DMA device to be performing DMA transfers in one of three modes:
- memory to memory
- devices to memory
- memory to device
Which mode is used is expected to be determined at system creation time.
In the case of the altera_avalon_dma driver, this is actually done through a run time ioctl call. The bug occurs if you have run the DMA in one of these modes, and then make the ioctl call to change to one of the other modes.
This is in any case not an efficent way to make use of the DMA controller, since the pending transfer queues will need to be drained between the ioctl calls. It is better to provide additional DMA channels instead.