Altera_Forum
Honored Contributor
21 years agoStreaming DMA UART
Quartus II Version 4.00 SP1 Full Version
Nios II Version 1.0.0 (With SP1) I'm trying to create a very simple system of streaming characters from memory UART using the DMA. The purpose is just to test the DMA streaming function(s). The system consist of a Nios II/s cpu along with 24kbytes of onchip ram for the code. The peripherals consist of two uarts along with the DMA. The dma read master is connected to the onchip ram, and the dma write master is connected to the second uart (verified). Both uarts use the default configuration. It also has sram defined in the system, but I don't have it being used within the code anymore (I was originally trying to stream from it to the uart). The first uart is setup in the system library to be used as the stdout, stderr, stdin. The onchip ram is set within the system library as the program memory, read-only memory, and read/write memory. The issue I'm having is the actual DMA transfer never completes. The dma_done function within my code never gets called, and I don't see any data come out of the second uart. Here is the code. # include <stdio.h># include <stdlib.h># include "sys/alt_dma.h"# include "system.h"# include "alt_types.h" alt_u8 buffer[16] __attribute__ ((section (".onchip_ram"))) = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, /* 0-9 */ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66 }; /* a-f */ static volatile int dma_complete = 0; void dma_done (void* handle) { dma_complete = 1; } int main(int argc, char* argv[], char* envp[]) { int rc; void* tx_data = (void*) &buffer[0]; printf("Hello from Nios II!\n"); alt_dma_txchan tx; if ((tx = alt_dma_txchan_open("/dev/dma")) == NULL) { printf("Failed to open device!\n"); exit(1); } alt_dma_txchan_ioctl(tx, ALT_DMA_RX_STREAM_ON, (void*) 0x01); dma_complete = 0; if ((rc = alt_dma_txchan_send (tx, tx_data, 4, dma_done, NULL)) < 0 ) { printf("Failed to post transmit request!, reason = %i\n", rc); exit(1); } while (!dma_complete); alt_dma_txchan_close (tx); printf("Transaction Complete!\n"); return 0; } Small C library, and Reduced device drivers are checked to get it to fit within the 24k bytes. It takes up about 9k, and the rest is for the stack + heap. My belief is that I don't have the address of the uart defined correctly. I tried using the base address of that uart plus the offset to the write register, but that didn't work either. I haven't seen an example of a streaming dma function that shows me how to define it.