我在NIOS2中加入了DMA外设
现透过DMA来传输两个数组中的数据,但是为何传送后的数据有问题?
例如传输前是1.2.3.4.5.6.7.8.9
传送后就变为1.2.4.3.6.5.11.9.8
我的程序是
#include "system.h"
#include "altera_avalon_pio_regs.h" #include "altera_avalon_uart_regs.h" #include "altera_avalon_timer_regs.h" #include "altera_avalon_dma_regs.h"
#include "alt_types.h" #include "sys/alt_irq.h"
alt_u8 *p_sbuff; volatile alt_u8 chr[] = {1,2,3} ; volatile alt_u8 chr2[20] ; alt_u8 chars = 'y';
void DMA0_init();
/********************************************************************** * * Function: int main() * * Description: The main function * * * Notes: * * Returns: None defined. * **********************************************************************/ int main (void) {
DMA0_init();//start dma
while (1) { }
return 0; }
/********************************************************************** * * Function: DMA0_Init() * * Description: Initialize The DMA0 * * * Notes: * * Returns: None defined. * **********************************************************************/
void DMA0_init() { alt_u16 control_value; IOWR_ALTERA_AVALON_DMA_STATUS(DMA_0_BASE, 0x00); //Clear the status register IOWR_ALTERA_AVALON_DMA_RADDRESS(DMA_0_BASE, chr); //Write the read dress , for IOWR_ALTERA_AVALON_DMA_WADDRESS(DMA_0_BASE, chr2); //Write the write dress , for UART0 IOWR_ALTERA_AVALON_DMA_LENGTH(DMA_0_BASE, 0x10); //Send eight bytes control_value = ALTERA_AVALON_DMA_CONTROL_HW_MSK+ALTERA_AVALON_DMA_CONTROL_GO_MSK + ALTERA_AVALON_DMA_CONTROL_LEEN_MSK ; IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_0_BASE, control_value);
}
|