我想将内存的数组用dma方式传送给串口,为什么不能进入中断,望高手指点,程序如下: 还有我想问下dma启动后传完数据后会自动再次不断的重新传输吗,我是菜鸟,不是很明白,谢谢 #include <stdio.h> #include <stdlib.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 "system.h" #include "alt_types.h" #include "sys/alt_irq.h" #include "sys/alt_dma.h" #include "unistd.h" volatile static alt_u8 chr[20] = {1,2,3,4,6,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20} ; void init_dma() { alt_u16 control_value;
IOWR_ALTERA_AVALON_DMA_CONTROL (DMA_0_BASE, 0); IOWR_ALTERA_AVALON_DMA_STATUS(DMA_0_BASE, 0); //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, (void* )UART_USB_BASE + 1); //Write the write dress , for UART IOWR_ALTERA_AVALON_DMA_LENGTH(DMA_0_BASE, 10); control_value = ALTERA_AVALON_DMA_CONTROL_BYTE_MSK | ALTERA_AVALON_DMA_CONTROL_GO_MSK | ALTERA_AVALON_DMA_CONTROL_I_EN_MSK | ALTERA_AVALON_DMA_CONTROL_WCON_MSK | ALTERA_AVALON_DMA_CONTROL_LEEN_MSK ; IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_0_BASE, control_value); } void dma_isr(void* context,alt_32 id) { printf("ceshi!"); int si=IORD_ALTERA_AVALON_DMA_STATUS (DMA_0_BASE); if(si&0x1) { IOWR_ALTERA_AVALON_DMA_CONTROL (DMA_0_BASE, 0); IOWR_ALTERA_AVALON_DMA_STATUS (DMA_0_BASE, 0); IOWR_ALTERA_AVALON_DMA_LENGTH (DMA_0_BASE, 10); IOWR_ALTERA_AVALON_DMA_RADDRESS (DMA_0_BASE,chr); IOWR_ALTERA_AVALON_DMA_WADDRESS (DMA_0_BASE,(void* )UART_USB_BASE + 1); IOWR_ALTERA_AVALON_DMA_CONTROL (DMA_0_BASE, ALTERA_AVALON_DMA_CONTROL_HW_MSK | ALTERA_AVALON_DMA_CONTROL_GO_MSK | ALTERA_AVALON_DMA_CONTROL_I_EN_MSK | ALTERA_AVALON_DMA_CONTROL_WCON_MSK | ALTERA_AVALON_DMA_CONTROL_LEEN_MSK); } } int main() { int s,i; alt_irq_register(DMA_0_IRQ,0,dma_isr); init_dma(); while(1) { ; }
} |