被逼无奈放弃了DMA,直接用USB EP4的FIFO把数据给读取了,同步是同步上了,可就是纳闷,为啥DMA不好使呢,问了几个人,都没碰上过这样的事儿,我把寄存器设置贴上,麻烦各位给看看
USB的
*(volatile BYTE *)&pHWHead->pUSBCtrlAddr->EP4DTL=USBD_GLOBALS_BUF_SIZE&0xff;
*(volatile BYTE *)&pHWHead->pUSBCtrlAddr->EP4DTM=(USBD_GLOBALS_BUF_SIZE>>8)&0xff;
*(volatile BYTE *)&pHWHead->pUSBCtrlAddr->EP4DTH=(USBD_GLOBALS_BUF_SIZE>>16)&0x0f;
*(volatile BYTE *)&pHWHead->pUSBCtrlAddr->OCSR2=
*(BYTE *)&pHWHead->pUSBCtrlAddr->OCSR2 | (BYTE)EPO_AUTO_CLR /*| EPO_OUT_DMA_INT_MASK*/;
//AUTO_CLR(OUT_PKT_READY is cleared automatically), interrupt_masking.
*(volatile BYTE *)&pHWHead->pUSBCtrlAddr->EP4DU=0x01; //DMA transfer unit=1byte
*(volatile BYTE *)&pHWHead->pUSBCtrlAddr->EP4DC=UDMA_OUT_DMA_RUN|UDMA_DMA_MODE_EN;
DMA3的
v_pDMAregs->DISRCC3 = (1<<1)|(1<<0); //src=APB, srcAddr=fixed
v_pDMAregs->DISRC3 = REAL_PHYSICAL_ADDR_EP4_FIFO; //srcAddr=EP4_FIFO
v_pDMAregs->DIDSTC3 = (0<<1)|(0<<0); //dst=AHB(memory),increase,
#if (DRIVER_GLOBALS_PHYSICAL_MEMORY_START<0xA0000000 || DMA_BUFFER_BASE<0xA0000000)
GENERATE_ERROR
//The above two address should be non-cacheable area.
#endif
realPhysicalAddr_UsbdRxBuf = \
(ULONG)&((DRIVER_GLOBALS *)DRIVER_GLOBALS_PHYSICAL_MEMORY_START)->usbd.usbdRxBuf \
- DMA_BUFFER_BASE + DMA_PHYSICAL_BASE;
//USBDMSG( 1, (TEXT( "[USBD:RPA_URxBuf=%x]"),realPhysicalAddr_UsbdRxBuf) );
//Real physical address of usbdShMem->usbdRxBuf
if(bufIndex==0)
{
v_pDMAregs->DIDST3=realPhysicalAddr_UsbdRxBuf+0+bufOffset;
}
else
{
v_pDMAregs->DIDST3=realPhysicalAddr_UsbdRxBuf+(USBD_GLOBALS_BUF_SIZE/2)+bufOffset;
}
v_pDMAregs->DCON3=(USBD_GLOBALS_BUF_SIZE-bufOffset)|(1<<31)|(0<<30)|(1<<29)|(0<<28)|(0<<27)|(4<<24)|(1<<23)|(1<<22)|(0<<20);
//handshake,requestor=APB,CURR_TC int enable,unit transfer,
//single service,src=USBD,H/W request,no_autoreload,byte,CURR_TC
v_pDMAregs->DMASKTRIG3=(1<<1); //DMA 3 on
DMA3的寄存器的值打印出来都是跟4.2里面一样的配置,可就是DCDST3 DSTAT一直是0
REAL_PHYSICAL_ADDR_EP4_FIFO明明都有数据到了,DMA就是不拷贝,不用DMA直接读就正确了,郁闷啊