Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

DMA transfer using HAL

Altera_Forum
Honored Contributor II
1,259 Views

I have seen DMA transfers from memory to a peripheral in SDK, but the HAL example in the software reference guide is not clear. How does one specify the constant destination address? Does it involve setting the transmission channel to streaming, by txchan_ioctl(tx, ALT_DMA_TX_STREAM_ON, (void *) dest_addr)? 

 

Comparing to the SDK example of this kind, in App note 333, for HAL how can one instantiate another transfer in the ISR (the callback function)? 

 

I appreciate your input and any sample code in HAL is very welcome. 

 

Mark
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
529 Views

The ioctl names are a little backwards, since they are described looking into the DMA rather than out of the DMA. However to do what you want, you can use: 

 

txchan_ioctl(tx, ALT_DMA_RX_STREAM_ON, (void *) dest_addr); 

 

From the 1.1 version of the kit, you can instead use the (hopefully) more intuitive: 

 

txchan_ioctl(tx, ALT_DMA_TX_ONLY_ON, (void *) dest_addr); 

 

to write to a single location, or: 

 

txchan_ioctl(tx, ALT_DMA_RX_ONLY_ON, (void *) dest_addr); 

 

to read from a single location. 

 

The old names (like ALT_DMA_RX_STREAM_ON) will continue to work, but I'd recommend using these new defines instead. 

 

With the HAL there is no need to start your next transfer in the ISR. You can call  

alt_dma_txchan_send() before the current transfer has completed. The new transfer will be queued and then started as soon as the device is ready. 

 

You can, if you wish, call alt_dma_txchan_send() from within the "done" callback function of the previous transfer. This will achieve what you are asking for - but will increase the amount of processing performed at ISR level. It will also increase the delay between transfers.
0 Kudos
Altera_Forum
Honored Contributor II
529 Views

I don't understand what you mean by  

 

"looking into the DMA rather than out of the DMA" 

 

With Nios II 1.00 (the version I have) I have to use the ALT_DMA_RX_STREAM_ON and the ALT_DMA_TX_STREAM_ON macro's versus the new ones. 

 

The issue I have is the confusion in regards to what they mean. You say its backwards, but the Nios II processor reference handbook for the previous version uses identical wording to describe ALT_DMA_TX_STREAM as the new version does when it describes ALT_DMA_TX_ONLY_ON 

 

Old NIOS II Processor Reference Handbook 

ALT_DMA_TX_STREAM_ON 

"Sets a DMA tranmitter into streaming mode. In this case, data is written continously to a single location. The "arg" parameter specifies the address to write to." 

 

New NIOS II Processor reference Jandbook 

ALT_DMA_TX_ONLY_ON 

"Sets a DMA transmitter into streaming mode. In this case, data is written continously to a single location. The "arg" parameter specifies the address to write to. 

 

The only difference to me is just a typo with "tranmitter" in the old version of the manual. 

 

Is the old manual just wrong based on your testing? 

 

UPDATE - Nevermind I saw your explantion in another thread. The documentation is either wrong or just misleading.
0 Kudos
Reply