EmbeddedRelated.com
Forums

LPC214x: USB hangs after some hours

Started by gcopoix January 13, 2006
Hello philipsapps (Tom),

I have had some (a LOT) of stability issues with the Keil examples, 
and I was about to incorporate the changes you outlined below. The 
WRCmd, WrCmdDat and rdCmdDat are easy enough to change in the Keil 
samples, however the USB_INT is not like the "original code" you 
show below. The versions on keil.com is 1.00 and you mention v 
1.04 ?? Any idea as to what must be changed in USB_ISR in the 
current 1.00 (which is the only one available from keil at the 
moment)

Regards,
Carsten

--- In lpc2000@lpc2..., "philips_apps" <philips_apps@...> 
wrote:
>
> Lately, I have been scratching my head to get the LPC2148 USB 
> device pass the USBCV test downloaded from "http://www.usb.org".
> 
> Using latest Keil's USB MSC sample, v1.04, the enumeration test 
> will fail from time to time, and program would spin in the 
> WrCmd() or WrCmdDat() routine forever.
> 
> While I was looking into the WrCmd(), WrCmdDat() and RdCmdDat()
> routine and ISR carefully, Keil just found one problem that could
> screw up the USB protocol engine.
> 
> In the USB device block, the registers are located in the VPB
> clock domain, which requires minimum 18Mhz PCLK. in the original 
> MSC example, PCLK uses the default value 1/4 of CCLK = 15Mhz in
> the startup.s. That has probably caused most of the intermitten 
> problems in these Wr/RdCmdDat() modules. The PCLK should be set
> to >= 18Mhz.
> 
> I think that Keil will release a new version of these
> example based on the fixes soon. I am just glad that I am 
> finally able to use the latest fixes to pass all the compliance
> test. So, I pass around to those who had problems with the
> LPC2148 USB driver:
> 
>    Do the following steps:
>    (1) in startup.s, set: 
>     VPBDIV_SETUP    EQU     1
>     VPBDIV_Val      EQU     0x00000001 ; PCLK is set to CCLK 60Mhz
> 
>    (2) In usbhw.c, modify these modules, WrCmd(), WrCmdDat(), 
> and RdCmdDat() as below:
> 
> /*
>  *  Write Command
>  *    Parameters:      cmd:   Command
>  *    Return Value:    None
>  */
> 
> void WrCmd (DWORD cmd) {
> 
>   DEV_INT_CLR = CCEMTY_INT;
>   CMD_CODE = cmd;
>   while ((DEV_INT_STAT & CCEMTY_INT) == 0);
> }
> 
> /*
>  *  Write Command Data
>  *    Parameters:      cmd:   Command
>  *                     val:   Data
>  *    Return Value:    None
>  */
> 
> void WrCmdDat (DWORD cmd, DWORD val) {
> 
>   DEV_INT_CLR = CCEMTY_INT;
>   CMD_CODE = cmd;
>   while ((DEV_INT_STAT & CCEMTY_INT) == 0);
>   DEV_INT_CLR = CCEMTY_INT;
>   CMD_CODE = val;
>   while ((DEV_INT_STAT & CCEMTY_INT) == 0);
> }
> 
> /*
>  *  Read Command Data
>  *    Parameters:      cmd:   Command
>  *    Return Value:    Data Value
>  */
> 
> DWORD RdCmdDat (DWORD cmd) {
> 
>   DEV_INT_CLR = CCEMTY_INT | CDFULL_INT;
>   CMD_CODE = cmd;
>   while ((DEV_INT_STAT & CDFULL_INT) == 0);
>   return (CMD_DATA);
> }
> 
>     (3) in usbhw.c, in the interrupt handler, USB_ISR(), 
> comment out "DEV_INT_CLR = CDFULL_INT;" as seen below:
>           ...
>           EP_INT_CLR = 1 << n;
>           while ((DEV_INT_STAT & CDFULL_INT) == 0);
>           val = CMD_DATA;
> //          DEV_INT_CLR = CDFULL_INT;
> 
>           if ((n & 1) == 0) {              /* OUT Endpoint */
>             if (n == 0) {                  /* Control OUT Endpoint 
*/
>               if (val & EP_SEL_STP) {      /*
Setup Packet */
>                 if (USB_P_EP[0]) {
>                   USB_P_EP[0](USB_EVT_SETUP);
>                   continue;
>                 }
>               }
>             }
> 
> That will probably address many intermitten problems seen in the
> past. Meanwhile, we are working hard to improve our documentation
> in the USB chapter.
> 
> Regards,
> 
> Tom
> 
>
	

An Engineer's Guide to the LPC2100 Series

Carsten,

    I went to Keil's website a few days ago. In Keil's
weblink, "http://www.keil.com/download/docs/307.asp?bhcp=1" 
named "LPC2148 USB Mass Storage Device Example" is probably 
the earliest version of USB examples which has NOT been
updated.
    The newer version should be in the eval. version of 
Keil's uVision3 IDE, under "\Keil\ARM\Boards\Keil\MCB2140\".
You can download it from their website too. The latest should 
be v1.04.

Hopefully, it helps!

Tom
	--- In lpc2000@lpc2..., Carsten Gr <cgroen@...> wrote:
>
> Hello philipsapps (Tom),
> 
> I have had some (a LOT) of stability issues with the Keil 
examples, 
> and I was about to incorporate the changes you
outlined below. The 
> WRCmd, WrCmdDat and rdCmdDat are easy enough to change in the Keil 
> samples, however the USB_INT is not like the "original code" you 
> show below. The versions on keil.com is 1.00 and you mention v 
> 1.04 ?? Any idea as to what must be changed in USB_ISR in the 
> current 1.00 (which is the only one available from keil at the 
> moment)
> 
> Regards,
> Carsten
>