2020-02-21 06:25 AM
I want to send data with a data rate of about 5Mbit/s from my Nucleo L476RG board to Matlab using the USB interface with the CDC protocol.
For the USB connection I need to have 48MHz USB clock. I soldered a 8MHz / 16pF crystal at position X3 on the board and assembled C33 / C34 with 20 pF capacitors. In the Clock configuration I specified an external 8MHz source and set the USB clock to 48MHz. A blinking LED program shows me that the clock is correct.
But I am not able to use the port. What am I doing wrong?
For your information:
I use the Nucleo L476RG board. The PC runs with Windows 10.
The tool chain used is:
CubeMX 5.5.0 and SW4STM32 version Neon.3 release 4.6.3.
USB is connected as follows:
GND connected to Nucleo
VCC (+5V) not connected
D+ via a 1.5k pull up resistor to 3.3V and connected to PA12
D- connected with PA11
In CubeMX the following is set:
Connectivity:
USB_OTG_FS / Device_Only
"Activate_SOF" and "Activate_VBUS" are inactive.
Middleware: USB_Device / Communication Device Class (Virtual Port Com)
In the Project I increased the minimum heap size from 0x100 to 0x800.
In the main.c program the following 3 additions are made:
1)
/* Private includes --------*/
/* USER CODE BEGIN Includes */
#include "usbd_cdc_if.h"
2)
/* USER CODE BEGIN 2 */
HAL_Delay(1000);
uint8_t buffer[] = "Hallo, Welt!\r\n";
3)
/* USER CODE BEGIN WHILE */
while (1)
{
CDC_Transmit_FS(buffer, sizeof(buffer));
HAL_Delay(1000);
HAL_GPIO_TogglePin(LD2_GPIO_Port,LD2_Pin);