Getting sleep to work when USB CDC is enabled?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-26 5:29 AM
My program has the option of sleeping for a period using the RTC to wake or sleeping until the wakeup pin is set high. Both these functions work perfectly if I talk to the outside world using a uart.
However, I configure CDC as a serial port SLEEP doesn't work - or at least the USB never disconnects.
I'm using USB STOP and USB DEINIT before the sleep command but these don't seem to do anything. Any ideas appreciated
while(totalseconds>0){
if(totalseconds>30.0){
timetosleep=30*2048;
totalseconds-=30.0;
} else {
timetosleep= (int)(totalseconds*2048.0);
totalseconds=0.0;
}
USBD_Stop(&hUsbDeviceFS);
USBD_DeInit(&hUsbDeviceFS);
HAL_NVIC_SetPriority(RTC_WKUP_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn);
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, timetosleep, RTC_WAKEUPCLOCK_RTCCLK_DIV16);
HAL_SuspendTick();
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE);
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
HAL_NVIC_DisableIRQ(RTC_WKUP_IRQn);
}
SYSCLKConfig_STOP();
HAL_ResumeTick();
MX_USB_DEVICE_Init();
- Labels:
-
Power
-
STM32F4 Series
-
USB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-26 6:35 AM
Hi PMath.4,
Can you please provide the product or the MCU family you are working with ?
Best Regards,
Ons.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-26 8:24 AM
Oops - sorry. STM32F407VET
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-26 2:46 PM
And the hardware? Is this some "known good" board like Nucleo or Disco? Is there any external pullup to DP/DM?
What exactly means "USB never disconnects"?
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-27 1:19 AM
Standard wiring using the internal phy with a 22R to the pins and a 1.5K pulldown up on D+ at the USB socket.
"What exactly means "USB never disconnects"?"
Don't get the windows chime when a USB device disconnects even after calling the STOP and DEINIT commands. The chime only happens when I press reset to get out of whatever state the H/W is in i.e. completely unresponsive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-27 7:56 AM
What is
> 1.5K pulldown up on D+
so is it a pull*down* or a pull*up* (i.e. where is the other end connected)?
There is no such resistor to be on DM/DP in the 'F4xx. Read the Full-speed OTG PHY subchapter in RM0090.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-27 8:27 AM
Operating as device only not OTG. Pullup is standard to indicate to USB host that a device is connected and should be enumerated as full speed.
There is nothing wrong with the basic USB connection - it works perfectly. The issue is that it isn't releasing and as, unlike the NXP chips, the ST doesn't have a programmable pullup in the UP it has to be external.
Resetting the processor causes the PC to drop the connection and re-connect so there is something not happening in either STOP or DEINIT that isn't signalling the loss of connection to the PC as it should
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-27 8:53 AM
> unlike the NXP chips, the ST doesn't have a programmable pullup in the UP it has to be external.
This for 'F4 is not true. Have you read the chapter I told you to? Have you already thrown out that resistor?
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-27 9:37 AM
"This for 'F4 is not true. "
Accepted, but it says that is dependent on using VBUS which isn't configured or connected (optional in CubeMX) and can't be as the pin is in use.
All irrelevant though as the issue is that a simple reset frees the bus whereas stopping and de-initing doesn't so there is something missing in the implementation of either stop or de-init or I'm missing a step which I can't find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-02-27 12:24 PM
And have you already undone that resistor? It's a 10 seconds operation after the soldering iron has heated up.
JW
