STM32F4 Development Notes 8: Solving the USB CDC "The device cannot start" problem

Publisher:快乐飞跃Latest update time:2018-09-12 Source: eefocusKeywords:STM32F4 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    I have debugged the USB CDC device of STM32 many times. You can look at the logs written earlier. I have debugged different STM32 MCUs. I thought STM32F4 would be very simple, but it was full of pitfalls. I debugged it until midnight to solve the problem. I sorted out the problem again.

    The chip I am using now is STM32F401. In STM32CubeMX, follow the steps below to set it up.

    1. Set as full-speed slave device and do not perform USB power detection.


    2. Enable CDC and use the default settings for other settings.



    After downloading the program generated according to the above settings to the chip and connecting it to the computer, the default is as follows


    Looking closely at the details, the problem is this


    I have been searching for a long time but couldn't solve the problem. There is a saying on the Internet that you can change the usbd_conf.h file, as shown in the figure below, and set USBD_MAX_NUM_CONFIGURATION to 2. After using this method, the computer can recognize the device normally, but cannot complete the communication operation.


    There is really no other way, so I tried to adjust the stack value, which was solved by chance. The value I adjusted now is as follows, which is in the startup_stm32f401xc.s file.


    Now the communication is normal, as shown below.


    The main logic code is as follows:


int main(void)

{

uint8_t data[10] = {0,1,2,3,4,5,6,7,8,9};

 

  MX_ADC1_Init();

  MX_SPI1_Init();

  MX_USB_DEVICE_Init();

 

  while (1)

  {

if (Target.IsbMilliSecond_1000() == TRUE)

{

//¹¤×÷ָʾµÆ

Target.HAL.LED.Turn();

CDC_Transmit_FS(data, 10);

}

  }

}

    This adjustment method is too difficult, and STM32CubeMX needs to be improved.


Keywords:STM32F4 Reference address:STM32F4 Development Notes 8: Solving the USB CDC "The device cannot start" problem

Previous article:STM32F4 Development Notes 9: Detailed porting process of USB CDC driver
Next article:STM32F4 Development Notes 7: Timer driver porting

Recommended ReadingLatest update time:2024-11-15 10:16

Study STM32F429 clock system notes
1. Why does STM32 have multiple clock sources? First of all, STM32 itself is very complex, with many peripherals, but not all peripherals require such a high frequency as the system clock. For example, the watchdog and RTC only need a clock of tens of kilobytes. For the same circuit, the faster the clock, the greater
[Microcontroller]
Wei Dongshan Embedded Linux_Issue 3: USB Camera Monitoring_Adding Video Recording Function to Mobile App (I)
1. Brief description of mobile app functions 1) The JZ2440 development board acts as a camera monitoring device and streaming server, transmitting the collected camera video data to the mobile phone App in real time via WiFi. 2) The mobile app acts as a client, receives the camera video from the streaming
[Microcontroller]
S3C2440 USB device controller
The s3c2440 soc integrates a usb1.1 device controller, which can perform full-speed/low-speed control, interrupt and batch transmission. In addition to endpoint 0, it has four endpoints. Each endpoint can be used as an interrupt and batch endpoint. Each endpoint has a 128-byte FIFO, so the maximum packet of the endpoi
[Microcontroller]
STM32F407 ADC DMA multi-channel
This picture mainly adds one PA2, and you can also add as many channels as you want. The main differences from the above: 1. Set PA2 as analog input 2. Modify the number of channels ADC_InitStructure.ADC_NbrOfConversion = 2;/*2 channel 1*/ 3. Add ADC_RegularChannelConfig(ADC1,ADC_Channel_3,2,ADC_SampleTime_480Cycles);
[Microcontroller]
USB communication code based on 51 single chip microcomputer 372
#include include.h #include "INTRINS.h" #define OP_CMD 1 // Command opcode #define OP_DATA 0 // Data opcode #define DELAY_TIMES 8 // Delay 2 microseconds #define DELAY_CNT_NUMS 2*DELAY_TIMES // Number of clock cycles required for a delay of 2 microseconds (for a 22.1184MHz crystal, each microsecond contains 22.1184
[Microcontroller]
Design of embedded wireless transmission system based on USB interface
  The design of embedded wireless transmission system based on USB interface involves communication interface. In order to solve the serious shortage of serial and parallel ports of PC and facilitate the connection between instruments and equipment, a solution combining wireless transmission technology and USB interfac
[Microcontroller]
Design of embedded wireless transmission system based on USB interface
STM32F412 takes too long to erase internal FLASH
1 Introduction Customers reported that when using STM32F412, erasing sectors 8 to 11 took too long, causing an IWDG reset to be accidentally triggered. 2 Problem Analysis 2.1 Problem Details Through email and phone communication with the customer, we learned that the customer mainly wanted to use the internal FLASH
[Microcontroller]
STM32F412 takes too long to erase internal FLASH
Pico oscilloscope USB rate transmission bottleneck problem
Oscilloscopes are known for their large buffer capacity, which is higher than that of desktop oscilloscopes or similar PC oscilloscopes. Over the past 20 years, successive generations of PicoScope oscilloscopes have always been able to provide ultra-large buffer capacity that is better than any oscilloscope at any pric
[Test Measurement]
Pico oscilloscope USB rate transmission bottleneck problem
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号