STM32H755 USB CDC Help
Hi everyone,
I’d like to ask for your expertise. I’m working with a custom board based on the STM32H755ZIT, configured in LDO mode. My issue is that when I connect the board to my PC via USB to use the Virtual COM Port (VCP), the computer does not detect the device.
I haven’t encountered this problem on other boards I’ve used, such as those with STM32L4 or STM32WB, where USB VCP works as expected.
Is there a particular difference in the USB VCP implementation between the STM32H7 series and the STM32L4/WB series that I should be aware of?
Here is the noteworthy configuration of my project in CubeMX
- RCC, HSE=Crystal/Ceramic Resonator
- SupplySource = PWR_LDO_Supply (This is in line with my hardware design)
- Power Regulator Voltage Scale = Scale 2
- USB_OTG_FS,Mode=Device_Only
- USB_DEVICE_M7, Class For FS IP = Communication Device Class (Virtual Port Com)
For the code:
usbd_cdc_if.c
/* USER CODE BEGIN PRIVATE_VARIABLES */
USBD_CDC_LineCodingTypeDef LineCoding = {
115200, /* baud rate */
0x00, /* stop bits - 1 */
0x00, /* parity - none */
0x08 /* nb. of bits 8 */
};
/* USER CODE END PRIVATE_VARIABLES */
---
// icopied this code base on various example i encountered
static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length){
...
case CDC_SET_LINE_CODING:
LineCoding.bitrate = (uint32_t) (pbuf[0] | (pbuf[1] << 8) | (pbuf[2] << 16) | (pbuf[3] << 24));
LineCoding.format = pbuf[4];
LineCoding.paritytype = pbuf[5];
LineCoding.datatype = pbuf[6];
break;
case CDC_GET_LINE_CODING:
pbuf[0] = (uint8_t) (LineCoding.bitrate);
pbuf[1] = (uint8_t) (LineCoding.bitrate >> 8);
pbuf[2] = (uint8_t) (LineCoding.bitrate >> 16);
pbuf[3] = (uint8_t) (LineCoding.bitrate >> 24);
pbuf[4] = LineCoding.format;
pbuf[5] = LineCoding.paritytype;
pbuf[6] = LineCoding.datatype;
break;
...
on main.c
/* USER CODE BEGIN Includes */
#include "usbd_cdc_if.h"
/* USER CODE END Includes */
int main(void){
...
char xxx[10] = "Hello\r\n";
while (1){
CDC_Transmit_FS((uint8_t *)xxx, 7);
HAL_Delay(1000);
}
...
While browsing the STM32 firmware package, I came across the CDC_Stand_Alone example. I’d like to implement USB VCP on my custom board with the STM32H755ZIT, but I’m unsure how to port this example into my existing project since the structure differs quite a lot.
Any help would be appreciated.
IAN