Skip to Content
Block descriptionsUSB CDCUSB CDC Setup

USB CDC Setup Block Description

This block enables the configuration of the USB peripheral interface in CDC (Communication Device Class) mode within STM microcontrollers.



USB CDC Setup block

Table of Contents

Inputs

This block has no inputs.

Outputs

This block has no outputs.

Block Parameters

ParameterDescription
USB typeThe target USB peripheral module type:
USB_FS – Full Speed
USB_HS – High Speed
Size of RX bufferThe maximum data capacity allocated for the memory receive buffer.
Size of TX bufferThe maximum data capacity allocated for the memory transmit buffer.
Baudrate (bps)The serial data transmission rate evaluated in bits per second.
Stop bitsThe total number of stop bits appended to frame boundaries.
ParityThe error checking parity protocol type:
None – no parity bit
Even – even parity parity bit
Odd – odd parity parity bit
Number of bits (without stop bits)The character data payload word length (excluding stop bits).
Reset USB Pins on startEnables a force-reconnection routine by toggling the hardware state of the USB lines upon application initialization.
USB DP PortConditional Parameter
The GPIO alphanumeric port letter designated for the USB DP line. Supply this designator in a string format such as 'A', 'B', etc. This parameter is accessible only when the Reset USB Pins on start option is enabled.
PinConditional Parameter
The specific GPIO hardware pin number designated for the USB DP line. This parameter is accessible only when the Reset USB Pins on start option is enabled.
Tx wait for first RxStalls any active data transmission loops until at least one initial inbound packet is verified by the receiver subsystem.


Block parameters for USB CDC Setup

CubeMX Configuration for a Given MCU Model

The required hardware peripheral setup is detailed in the dedicated CubeMX Configuration for a Given MCU Model subpage.

Comments and Troubleshooting

”Error in open port” Exception

Should you encounter an “Error in open port” runtime exception, compile and run the firmware binary utilizing a dedicated Release optimization build profile.

USB CDC Setup Integration in FS Mode

To integrate the USB CDC Setup block in FS (Full Speed) operations, insert the following two source lines within the CDC_Control_FS routine implementation inside the usbd_cdc_if.c file:

extern int8_t USB_CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length); USB_CDC_Control_FS(cmd, pbuf, length);

After pasting the lines above, the project fragment should look like this:

CDC_Control_FS

USB CDC Setup Integration in HS Mode

To use the USB CDC Setup block in HS mode, add two lines in the CDC_Control_HS function in the usbd_cdc_if.c file:

extern int8_t USB_CDC_Control_HS(uint8_t cmd, uint8_t* pbuf, uint16_t length); USB_CDC_Control_HS(cmd, pbuf, length);

After pasting the lines above, the project fragment should look like this:

CDC_Control_HS

See Also

Last updated on