This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Register not getting set

I have the sample KEIL USB HID project for the LPC2148 and I have a project I started in which I am going through the KEIL code section by section attempting to thouroughly understand its function and tune the code for my needs.

In the KEIl project it runs this line of code fine, but in mine it freezes:

while((USBDevIntSt & 0x00000100) == 0);

Thanks for any help in advance!
Wesley

Parents
  • In the USBHID of current MDK-ARM (v4.72a), equivalent line appears on USB_ConfigEP() subroutine.

    C:\Keil\ARM\Boards\Keil\MCB2140\USBHID\usbhw.c
    
    /*
     *  Configure USB Endpoint according to Descriptor
     *    Parameters:      pEPD:  Pointer to Endpoint Descriptor
     *    Return Value:    None
     */
    
    void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) {
      U32 num;
    
      num = EPAdr(pEPD->bEndpointAddress);
      REALIZE_EP |= (1 << num);
      EP_INDEX = num;
      MAXPACKET_SIZE = pEPD->wMaxPacketSize;
      while ((DEV_INT_STAT & EP_RLZED_INT) == 0);    // <----
      DEV_INT_CLR = EP_RLZED_INT;
    }
    

    Above code lines exactly follow the example on the LPC2148 User Manual, chapter 9.7.12
    If the "while" clause wouldn't finish, you should pass bad parameter(s) to the USB registers, just before this line,
    - REALIZE_EP (USBReEp)
    - EP_INDEX (USBEpIn)
    - MAXPACKET_SIZE (USBMaxPSize)

    Tsuneo

Reply
  • In the USBHID of current MDK-ARM (v4.72a), equivalent line appears on USB_ConfigEP() subroutine.

    C:\Keil\ARM\Boards\Keil\MCB2140\USBHID\usbhw.c
    
    /*
     *  Configure USB Endpoint according to Descriptor
     *    Parameters:      pEPD:  Pointer to Endpoint Descriptor
     *    Return Value:    None
     */
    
    void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) {
      U32 num;
    
      num = EPAdr(pEPD->bEndpointAddress);
      REALIZE_EP |= (1 << num);
      EP_INDEX = num;
      MAXPACKET_SIZE = pEPD->wMaxPacketSize;
      while ((DEV_INT_STAT & EP_RLZED_INT) == 0);    // <----
      DEV_INT_CLR = EP_RLZED_INT;
    }
    

    Above code lines exactly follow the example on the LPC2148 User Manual, chapter 9.7.12
    If the "while" clause wouldn't finish, you should pass bad parameter(s) to the USB registers, just before this line,
    - REALIZE_EP (USBReEp)
    - EP_INDEX (USBEpIn)
    - MAXPACKET_SIZE (USBMaxPSize)

    Tsuneo

Children
  • This is identical logic to the code I am using in my project which is below and allows me to realize and setup the needed number of endpoints all at once which in my case is the first four endpoints:

    void realizeEndpoints(char count)
    { char i;

    for(i = 0; i < count; i++) { USBReEp |= (1 << i);

    USBEpInd = i; USBMaxPSize = 64;

    while((USBDevIntSt & 0x00000100) == 0); USBDevIntClr |= 0x00000100; }
    }

    When I run the sample code it goes over this line "while ((DEV_INT_STAT & EP_RLZED_INT) == 0);" with no problem but when i run my code it gets stuck on "while((USBDevIntSt & 0x00000100) == 0);" and they should be the same from what I can tell.

    And I am confused by "you should pass bad parameter(s)". So I should try and pass in bad data to registers and so forth to see if it also fails under those conditions?

    Thanks,
    Wesley