Altera_Forum
Honored Contributor
20 years agoIOWR and direct adress access
I can use IOWR,IORD and direct address access to operate SDRAM, But
i can not use address to access Uart, for example: 1. use address alt_u8 * UartTxAdr; UartTxAdr = UART0_BASE+1; //that can not send the data * UartTxAdr = 0x30; 2.use IOWR //that can send the data ok IOWR(UART0_BASE,1,0x30); I do not know what different between these two way. in my DMA operate code, from memory to uart, the code is as follow: static volatile int rx_done = 0; alt_u8 buffer[16] __attribute__((section(".sdram"))); static void done (void* handle, void* data) { rx_done++; } // in main function buffer[0]=0x30; //'0' buffer[1]=0x31; //'1' buffer[2]=0x32; //'2' buffer[3]=0x33; //'3' void* tx_data = (void*) &buffer[0]; /* pointer to data to send */ if ((txchan = alt_dma_txchan_open("/dev/dma_0")) == NULL) { IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 2); exit (1); } alt_dma_txchan_ioctl(txchan,ALT_DMA_SET_MODE_8,NULL); alt_dma_txchan_ioctl(txchan,ALT_DMA_RX_STREAM_ON,(void*)UART0_BASE+1); if ((rc = alt_dma_txchan_send (txchan,tx_data,4,done,NULL)) < 0) { IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 3); exit (1); } while (!rx_done); alt_dma_txchan_close(txchan); the code is execute OK, the rx_done is set, but the data never send out from the uart, maybe it can not use direct address access?? (i think the dma operate is use direct address operate), i add the uart0 in SOPC and set the "include end-of packet register", and connect DMA write-master to usrt0, read-master to sdram by set the small rect with "1", anyone can help me ????