- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I Have a program about DMA , isend data from RS232 to SDRAM, SDRAM can receive data ,bur when i check this data whther rightly, i find in't not the data that send from uart . the problem is i can't receive right data from uart. this problem have trouble me about 3 weeks .please give me a sugesttion and verify this programs. deeply thanks.
( Another program work rightly to send data from SDRAM to RS232 ,so SDRAM and RS232 work rightly) PLEASE HELP ME,THANK YOU the program is: //字符串写到SDRAM,再从SDRAM读到RS232# include <stdio.h># include <stdlib.h># include "sys/alt_dma.h"# include "altera_avalon_uart_regs.h"# include "system.h"# include "alt_types.h"# include <string.h> static volatile int tx_done = 0; volatile static char str[] = {"this is sdram data,written by memcpy function\n"} ;//待写到SDRAM的数据# define TRANSFER_LENGTH 1024 //回调函数 static void done (void* handle) { tx_done++; } int main() { alt_u8 i; FILE *fp_LCD=0; FILE *fp_RS232=0; fp_LCD = fopen("/dev/lcd","w"); fp_RS232 = fopen("/dev/rs232","w"); int rc; alt_dma_txchan txchan; void* source = (void*)(SDRAM_BASE);/* 源地址 */ void* dest = (void*)IOADDR_ALTERA_AVALON_UART_TXDATA(RS232_BASE); //memset(SDRAM_BASE,'aaaaaaaaaaaaaaaa',TRANSFER_LENGTH); memcpy(SDRAM_BASE,str,strlen(str)); //将STR地址中的字符串写到SDRAM /* 打开发送通道 */ if ((txchan = alt_dma_txchan_open("/dev/dma")) == 0) { printf ("successful to open transmit channel\n"); exit (1); } /* 设置目标地址固定 */ if ((rc = alt_dma_txchan_ioctl(txchan, ALT_DMA_TX_ONLY_ON, dest)) < 0) { printf ("Failed to set ioctl, reason = %i\n", rc); exit (1); } //设置每次发送一个字节,即8位,因为UART每次只发送8位 if((rc = alt_dma_txchan_ioctl(txchan,ALT_DMA_SET_MODE_8 ,NULL))<0) { printf("Failed to set mode 8\n"); exit(1); } /* 开始发送 */ if ((rc = alt_dma_txchan_send(txchan, source, strlen(str), done, NULL)) < 0) { printf ("Failed to post transmit request, reason = %i\n", rc); exit (1); } /* 等待发送结束 */ while (!tx_done); printf ("Transfer to jtag!\n"); fprintf(fp_LCD,"Transfer to lcd! \n"); fprintf(fp_RS232,"Transfer to rs232 ! \n"); for(i=0;i<=strlen(str);i++) { printf ("%s\n",(SDRAM_BASE+i)); fprintf(fp_LCD,(SDRAM_BASE+i)); //fprintf(fp_RS232,SDRAM_BASE); } return 0; }Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SORRY, the software visions :
quartus 10.0+NIOS 10.0- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need sdram to uart ,trying for 2 weeks but could not make it work.
will you share for me.I will be thankful to u.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it seems you need rx channel instead of tx channel.see embedded guide.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page