Forum Discussion
Altera_Forum
Honored Contributor
15 years agoAnother question:
I try also to transmit data from a variable (placed in the SRAM) to the UART with a DMA. I write a easy test software, but the result is strange. This is the code: printf("Hello from DMA?!\n"); IOWR_ALTERA_AVALON_UART_DIVISOR(SERIAL_UART_BASE,108); // Baud Rate: 921600 @ 100Mhz alt_u8 *tx_buffer = alt_uncached_malloc(BUFF_SIZE * sizeof (alt_u8)); tx_buffer = "Hello World\0"; printf("tx buffer position: 0x%X \n",tx_buffer); IOWR_ALTERA_AVALON_DMA_STATUS(DMA_BASE, 0); IOWR_ALTERA_AVALON_DMA_RADDRESS(DMA_BASE, tx_buffer); IOWR_ALTERA_AVALON_DMA_WADDRESS(DMA_BASE, SERIAL_UART_BASE+1); // TxData address is @ SERIAL_UART_BASE + 1(offset) IOWR_ALTERA_AVALON_DMA_LENGTH(DMA_BASE, 12); IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_BASE, 0x289); usleep (500000); printf("status: 0x%X \n",IORD_ALTERA_AVALON_DMA_STATUS(DMA_BASE)); printf("read add: 0x%X \n",IORD_ALTERA_AVALON_DMA_RADDRESS(DMA_BASE)); printf("write add: 0x%X \n",IORD_ALTERA_AVALON_DMA_WADDRESS(DMA_BASE)); printf("length: 0x%X \n",IORD_ALTERA_AVALON_DMA_LENGTH(DMA_BASE)); printf("control: 0x%X \n",IORD_ALTERA_AVALON_DMA_CONTROL(DMA_BASE)); The DMA write 2* '\0' chars and 3* 'H' chars (look the attachment). Why? The console output is right: Hello from DMA?! tx buffer position: 0x288F638 status: 0x11 // Operation Done - len = 0 read add: 0x288F644 // 0x288F638 + C(12) write add: 0x2903461 length: 0x0 control: 0x289 Regards