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.
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
- Popular Resources
- Popular amplifiers
- Virtualization Technology Practice Guide - High-efficiency and low-cost solutions for small and medium-sized enterprises (Wang Chunhai)
- usb_host_device_code
- Detailed explanation of big data technology system: principles, architecture and practice (Dong Xicheng)
- Image acquisition and processing system for panoramic map applications
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- si114x infrared sensor
- How can we add isolation to an ADC without compromising its performance?
- [[HC32F460 development board review] (Part 2) Review of three low-power modes of the HC32F460 microcontroller
- TI's Sitara AM3352 processor with up to 1 GHz and rich peripheral resources
- ESP-S3-12K (IV) ---- Here comes the ESP-box effect
- Pre-registration for the prize live broadcast: ADI's vital signs monitoring solutions in wearable products
- Fun Oscilloscope + Plot Heart
- [Review of SGP40] Rapid deployment of AI ambient air quality tracking model #3 I2C and UART interface selection
- Signal Generator and DA Conversion FPGA Case Tutorial
- Hardware Design Guide for TMS320F28xx and TMS320F28xxx DSCs