cancel
Showing results for 
Search instead for 
Did you mean: 

USB suspend example

rubenruizmontero
Associate II
Posted on December 21, 2011 at 18:12

When I try to enter in suspend mode, as soon as I set it, always receive a wake up interrupt request, and can't do it. I'm not sure if I do the correct process, just set FSUSP and then LP_MODE bit, in USB_CNTR register.

Is there any consideration to take into account?

I'm looking for an USB example to enter suspend mode or forum discussions, but can't find any solved...

Thank you in advance.
10 REPLIES 10
rosarium
Associate II
Posted on December 22, 2011 at 06:36

Following is an example:

----------------------------

/*******************************************************************************

* Function Name  : Suspend

* Description    : sets suspend mode operating conditions

* Input          : None.

* Output         : None.

* Return         : USB_SUCCESS.

*******************************************************************************/

void Suspend(void)

{

  /* suspend preparation */

  /* ... */

 

#ifndef STM32F10X_CL

  uint16_t wCNTR;

  /* macrocell enters suspend mode */

  wCNTR = _GetCNTR();

  wCNTR |= CNTR_FSUSP;

  _SetCNTR(wCNTR);

#endif /* STM32F10X_CL */

 

  /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */

  /* power reduction */

  /* ... on connected devices */

#ifndef STM32F10X_CL

  /* force low-power mode in the macrocell */

  wCNTR = _GetCNTR();

  wCNTR |= CNTR_LPMODE;

  _SetCNTR(wCNTR);

#endif /* STM32F10X_CL */

  /* switch-off the clocks */

  /* ... */

  Enter_LowPowerMode();

} //-------------------------------------------------------

/*******************************************************************************

* Function Name  : Enter_LowPowerMode

* Description    : Power-off system clocks and power while entering suspend mode

* Input          : None.

* Return         : None.

*******************************************************************************/

void Enter_LowPowerMode(void)

{

  /* Set the device state to suspend */

  bDeviceState = SUSPENDED;

}

//---------------------------------------------------------------

rosarium
Associate II
Posted on December 22, 2011 at 06:41

also if you want to leave low power mode you can use the followinf example.:

------------------------------------------------------

/*******************************************************************************

* Function Name  : Leave_LowPowerMode

* Description    : Restores system clocks and power while exiting suspend mode

* Input          : None.

* Return         : None.

*******************************************************************************/

void Leave_LowPowerMode(void)

{

  DEVICE_INFO *pInfo = &Device_Info;

  /* Set the device state to the correct state */

  if (pInfo->Current_Configuration != 0)

  {

    /* Device configured */

    bDeviceState = CONFIGURED;

  }

  else

  {

    bDeviceState = ATTACHED;

  }

}

rosarium
Associate II
Posted on December 22, 2011 at 06:47

for details you can refer to 

Mass storage demo: Bulk transfer

 in um0424 @

http://www.st.com

rubenruizmontero
Associate II
Posted on December 22, 2011 at 09:41

Thank you for your response Pila. That's what I'm trying to do, but the Host (PC), as soon as suspend mode is set, a wake up interrupt is received in device.

rosarium
Associate II
Posted on December 22, 2011 at 11:26

do you have any USB trace to cite your problem???

rubenruizmontero
Associate II
Posted on January 02, 2012 at 12:39

Thank you for your response, I was out of the office. What do you mean with USB trace? An image of all sent and recieved frames?

I use USB analyzer to see all data transit. I can't see anything strange, but if you think, it will be useful for you, I can try to get a capture.

rosarium
Associate II
Posted on January 03, 2012 at 09:05

Yes it will be more clear from a trace (CATC / Lecroy or any other USB analyser).

ashsanjose
Associate
Posted on October 19, 2012 at 22:58

Ruben,

I know it has been a while, but did you resolve this issue?  How? We are experiencing a similar issue.

Thanks,

Dan Ash

Synaptics Inc.

tsuneo
Senior
Posted on October 20, 2012 at 07:03

I have an impression that you are forcing entire device in suspend just by the device side reason. It isn't right way for the USB engine. The USB device engine accepts Suspend setting, just when the bus goes to idle by the host more than 3ms. While the host puts SOF signaling at every 1ms, the device immediately get resumed, even if the firmware would set Suspend bit of the engine. You can make the USB engine Suspend, just when bus suspend (idle) is reported by the engine.

You may keep core and other peripherals in suspend, even while the USB engine does not suspend. When the USB engine requires firmware intervention, it raises USB interrupt. You may keep the core in suspend until this event occurs.

Tsuneo