stm32usb library bug and solution

Publisher:luanzgcLatest update time:2018-09-20 Source: eefocusKeywords:stm32  bug Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

When I was developing the stm32usb device for my project, I found that the usb sending would often block the main function, or the program could not run smoothly, and the real-time performance was greatly reduced. It was normal for it to be stuck for tens of milliseconds. I don't understand why st would write such a usb program. It's really stupid. After several twists and turns, I found a solution:

In the usb_dcusb_dcd_int.c file, the function DCD_WriteEmptyTxFifo has a bug, which will often cause an infinite loop and make the USB library take too long.
It should be modified as follows, adding the statement in the red box to the original program:

The USB connection is not a reliable real-time connection, and it is normal to lose packets sometimes. After the modification, the USB will no longer be blocked and will be very smooth, but you should pay attention to adding packet loss processing logic to solve the USB packet loss problem. I am using a USBHID device, and the source code of the upper computer three platforms is attached https://download.csdn.net/download/u012572552/10612090


Keywords:stm32  bug Reference address:stm32usb library bug and solution

Previous article:STM32 routine USB HID bidirectional data transmission
Next article:STM32 USB HID custom device bulk transmission

Recommended ReadingLatest update time:2024-11-16 11:50

About the problem of garbled characters in the first character of the STM32 serial port
Problem: When using the sscom32 serial port debugging assistant, the first character appears garbled "tarttarttarttarttart" Cause: The baud rate is too high Solution: Set the baud rate to a lower value, usually 9600. Phenomenon: garbled code means the baud rate is high; normal display baud rate is low     The
[Microcontroller]
About the problem of garbled characters in the first character of the STM32 serial port
The real culprit of STM32 hardware error HardFault_Handler
There are two main reasons why the HardFault_Handler fault occurs in STM32: 1. Memory overflow or out-of-bounds access. 2. Stack overflow. The problem I encountered recently is stack overflow. The situation is as follows. Let me give you an example: static char data ; void fun1(unsigned char *buf) { int i=0; for(i=0
[Microcontroller]
FreeRTOS interrupt settings based on STM32 applications
1. Introduction to FreeRTOS interrupt settings Two macros are defined in FreeRTOSConfig.h: configKERNEL_INTERRUPT_PRIORITY configMAX_SYSCALL_INTERRUPT_PRIORITY        ​configKERNEL_INTERRUPT_PRIORITY is used to set the interrupt priority of the RTOS kernel. Because the RTOS kernel interrupt is not allowed to p
[Microcontroller]
FreeRTOS interrupt settings based on STM32 applications
Selection of reference source
tl431 lm285    385 or the like, 1.2V The AD reference voltage requirement of STM32 is >2.4V   REF2930-3V costs more than 20 yuan, which is too high. Chaliyuan only quoted a few yuan. Is there a problem with TI's supply? Since 3.0V references are rare and hard to find, I want to use 2.5V references. For 3V voltag
[Microcontroller]
Getting Started with STM32 Function Library External Interrupts
      Without further ado, let me first take a look at the button schematic on my Alienware development board.         The board is lazy, or it is called making full use of the pull-up function of the IO port, and no common pull-up resistor is added here. When programming, just enable the pull-up of the IO~ Look a
[Microcontroller]
Getting Started with STM32 Function Library External Interrupts
Design of voice guide system based on STM32
    There are several ways to provide voice guides for scenic spots: one is to receive navigation information from working satellites through the user terminal of the global positioning system (GPS), thereby solving the latitude and longitude information of the vehicle, and then calculating the real-time coordinates, c
[Microcontroller]
Design of voice guide system based on STM32
STM32 delay to eliminate jitter personal understanding
Today I found this sentence in an interrupt service subroutine. delay_ms(10); //De-jittering   So I am very curious about what jitter is, why we need to eliminate jitter, and how to eliminate jitter. 1. Let’s first talk about what jitter is: Usually the switches used for buttons are mechanical elastic switches.
[Microcontroller]
STM32 delay to eliminate jitter personal understanding
How to use the STM32 window watchdog
The 32F window watchdog has a 7-bit down counter that generates a watchdog reset in one of the following two situations:   1) When the counter value decreases from 0x40 to 0x3F 2) When the counter value is greater than a certain set value when refreshing the watchdog, this set value is defined in the WWDG_CFR regi
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号