LPC1857 USB1 port suspend

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1857 USB1 port suspend

787 Views
vivienwong
Contributor I

Hi,

   I am trying to suspend the USB 1 port. The LPC1857 is the Host and I have a fingerprint module connected to USB1.

Here is my code and the chip hangs up (when I run in debug mode with LPC link, it shows that CPU is stalled when i run this code).

void USB1_ForcePortSuspend()
{
    // only set suspend bit if the port is currently enabled (PE bit set to 1)
    if (LPC_USB1->PORTSC1_H & (1 << 2))
    {
        LPC_USB1->PORTSC1_H |= 1 << 7; // Enable suspend bit

        // wait for port to suspend
        while (!(LPC_USB1->PORTSC1_H & (1 << 7)));

        vTaskDelay(1000);

        // now suspend the PHY Clock
        LPC_USB1->PORTSC1_H |= (1 << 23);

//         wait for the clock to suspend
        while (!(LPC_USB1->PORTSC1_H & (1 << 23)));

        vTaskDelay(10);
    }
}

Is there a recommended step to suspend the USB 1 port?

Just to add on that it is when i suspend the PHY clock that the CPU gets stalled.

Thanks!

0 Kudos
Reply
2 Replies

605 Views
soledad
NXP Employee
NXP Employee

Hello Vivien, 

Let share my findings with you,  since you are using the LPC USB port as a Host,  then the device that it is going to be attach to the USB need to be first enter into Suspend Mode before you put the LPC USB host port into Suspend Mode, so first you need to see if the device connected to the HOST it is already in Suspend and then use your function with only

void USB1_ForcePortSuspend()
{

//FIRST CHECK IF DEVICE IT IS IN SUSPEND
    // only set suspend bit if the port is currently enabled (PE bit set to 1)
    if (LPC_USB1->PORTSC1_H & (1 << 2))
    {
        LPC_USB1->PORTSC1_H |= 1 << 7; // Enable suspend bit

 

        // wait for port to suspend
        while (!(LPC_USB1->PORTSC1_H & (1 << 7)));

 

        vTaskDelay(1000);

 

    }
}

 

Hope this clarifies

Have a nice day!

Best Regards,

Sol

605 Views
vivienwong
Contributor I

Thank you!

0 Kudos
Reply