Forum Discussion
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...
Altera_Forum
Honored Contributor
21 years agoUpdate:
Fixed the issue with the addressing, specified 8 bit transfers, and changed it around to use external memory. I also specified within the SOPC to only allow 8 bit transfers for the DMA. I'm not sure why I had to specify it in both the C code and the SOPC. It now seems to work. I haven't tested it with onchip memory yet. # include <stdio.h># include <stdlib.h># include "sys/alt_dma.h"# include "system.h"# include "alt_types.h" alt_u8 buffer[16] __attribute__ ((section (".ext_ram"))); static volatile int dma_complete = 0; void dma_done (void* handle) { dma_complete = 1; } int main(int argc, char* argv[], char* envp[]) { int rc; buffer[0] = 0x30; buffer[1] = 0x31; buffer[2] = 0x32; buffer[3] = 0x33; 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_SET_MODE_8, NULL); alt_dma_txchan_ioctl(tx, ALT_DMA_RX_STREAM_ON, (void*) UART1_BASE+1); 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; }