2020-12-18 06:28 AM
Hello,
I'm using STM32WB55 for a while but I am quite new for using the different power modes. I am using the USB-VCP in order to open a virtual com port and my aim is controlling the board according to the data on the USB-VCP line. I can successfully receive and send data through this line.
However, I would like to put the board into Stop1 mode when there is no data is transffered and wake up with the interrupt on this USB-VCP line. If there is a specific character 's' on this line, I can go into Stop1 mode, however, I cannot wake up the board after this step. My aim is keeping the connection and waking up the board with a specific character 'w' on USB-VCP line. Here is my receive data handler under usbd_cdc_if.c file;
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
{
/* USER CODE BEGIN 6 */
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
char *str = 0;
if (*Buf == 's') {
str = "S is pressed. Going into sleep mode\n\r";
CDC_Transmit_FS((uint8_t*)str, strlen(str));
HAL_SuspendTick();
HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);
} else if (*Buf == 'w') {
SystemClock_Config();
HAL_ResumeTick();
str = "W is pressed\n\r";
CDC_Transmit_FS((uint8_t*)str, strlen(str));
}
return (USBD_OK);
/* USER CODE END 6 */
}
I am checking the reference manua at the same time but I am stucked. I will be glad, if someone suggest me the steps that I should follow or at least whether waking up from STOP1 mode with the USB-VCP data is possible or not. Thanks in advance.
Regards,
Ozan
2020-12-18 06:50 AM
Hello Ozan,
USB peripheral on all STM32 is not fully functional in stop mode. Only USB wake-up signal detection is supported when MCU in stop mode. Your idea to change power mode using detection of received token is not feasible. Please check STM32Cube repository, there are also examples (mostly for HID) how to handle USB in stop mode.
Best regards,
Lubos
2020-12-18 06:56 AM
Hi Lubos,
Thank you for your fast reply. That's good to now that my idea won't work. I also checked the STM32Cube repository for the USB-CDC and the low power examples, however, I couldn't find a proper example that fits my usage.
I also looked for the PWR_OptimizedRunMode in order to reduce the system clock and put the board into LowPowerRunMode but in this case board again goes into low power mode but it is not possible to go back into run mode again. Do you have any suggestions that I should have a look at?
Best regards
Ozan