Hi every body I want to get data from PC and store in arm memory and after process sent by ssp. I use usb_cdc mode and i can't initialize usb in DMA mode. I use uvision 5 and the project is here: Download: www.transferbigfiles.com/.../9MUgnGGqw9o8a39vyHIdUA2
Thanks Dear Tsuneo Chinzei I have some question: 1- I want to send data from PC via usb (cdc_mode) 64Byte packet to hardware, witch endpoint i should enable? out or in (I use EP2 and set endpoint 2 out) This parameter is set in usbcfg.h :
#define USB_POWER 0 #define USB_IF_NUM 4 #define USB_EP_NUM 32 #define USB_MAX_PACKET0 64 #define USB_DMA 1 #define USB_DMA_EP 0x00000010
2- I use the code below in USB_EndPoint2 (uint32_t event) and always the first event is "USB_EVT_OUT_DMA_ERR" what is the reason?
if (event == USB_EVT_OUT_DMA_EOT) { /* End of Transfer */
} if((event == USB_EVT_OUT_DMA_ERR)||(event == USB_EVT_OUT_NAK)) {
} if (event & USB_EVT_IN_DMA_NDR) { DD.BufAdr = (uint32_t)DataBuf ; //+ DataIn; /* DMA Buffer Address */ DD.BufLen = 64; /* DMA Packet Count */ DD.MaxSize = 64; /* Must be 0 for Iso Transfer */ DD.InfoAdr = (uint32_t)InfoBuf; /* Packet Info Buffer Address */ DD.Cfg.Val = 0; /* Initial DMA Configuration */ DD.Cfg.Type.IsoEP = 0; /* Iso Endpoint */ DD.Cfg.Type.ATLE = 0; /* Iso Endpoint */ DD.Cfg.Type.Link = 0; USB_DMA_Setup(0x02, &DD); /* Setup DMA */ USB_DMA_Enable(0x02); /* Enable DMA */ LPC_USB->USBDMARSet |= 0x20; }
3- Is USBDMARSet set correct?
Thanks a lot.
> 1- I want to send data from PC via usb (cdc_mode) 64Byte packet to hardware, witch endpoint i should enable? out or in (I use EP2 and set endpoint 2 out)
As USB is host-centric, OUT: host -> device IN: device -> host
OUT EP2 (logical) = physical EP 4 "#define USB_DMA_EP 0x00000010" is right definition for this endpoint.
>2- I use the code below in USB_EndPoint2 (uint32_t event) and always the first event is "USB_EVT_OUT_DMA_ERR" what is the reason? > 3- Is USBDMARSet set correct?
The first "event" of this OUT EP should be NDDR (USB_EVT_OUT_DMA_NDR) But your code assigns "USB_EVT_IN_DMA_NDR" case to it. Replace "IN" to "OUT" Also, "LPC_USB->USBDMARSet |= 0x20;" is not required for the OUT endpoint.
Tsuneo