Board logo

标题: DMA求助!?? [打印本页]

作者: Masterine    时间: 2006-2-6 23:08     标题: DMA求助!??

我在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);    


}


 


 


 


 


 


 


 



 


作者: kzw    时间: 2006-2-10 17:03

你用标准做法师一下,
函数alt_dma_txchan_open (“/dev/dma_0”);
函数int alt_dma_txchan_send (alt_dma_txchan dma,
const void* from,
alt_u32 length,
alt_txchan_done* done,
void* handle);
函数int alt_dma_rxchan_prepare (alt_dma_rxchan dma,
void* data,
alt_u32 length,
alt_rxchan_done* done,
void* handle);
作者: Masterine    时间: 2006-2-10 22:46

感谢版主,我去试一下




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0