cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7/HAL/RTOS/Castom HID USB. The microcontroller freezes when receiving via USB at any time (from 20 minutes to 5 hours).

ISely.1
Associate II

Hello! I just broke my brain. In my responsible product, STM32H7 communicates with a personal computer in a Windows 10 environment. I created my project using the HAL environment in STM32CubeMX. To monitor the data exchange, I use a special counter that increases in when the USB receiver is interrupted. This is the place in the program:

static int8_t CUSTOM_HID_OutEvent_FS(uint8_t event_idx, uint8_t state)

{

 /* USER CODE BEGIN 6 */

count_HID_RX++; // counter of received packets for exchange control

......

}

Then I periodically check the value of this counter in an interruption from the RTC with a frequency of one second and reset it. If it is > 0, then the reception is on. The received data is processed in one of the RTOS tasks (which is clocked by the timer TIM6). There are 6 tasks in total and they all have the same stack and priority:

 /* definition and creation of Task_USB */

 osThreadDef(Task_USB, StartTask_USB, osPriorityIdle, 0, 128);

 Task_USBHandle = osThreadCreate(osThread(Task_USB), NULL);

 /* definition and creation of Task_OLED */

 osThreadDef(Task_OLED, StartTask_OLED, osPriorityIdle, 0, 128);

 Task_OLEDHandle = osThreadCreate(osThread(Task_OLED), NULL)

...etc

Interrupt priority at TIM6=0, USB=5. Minimum heap size=0x400,stack size=0x800. Everything works fine, but at some point (it may be after 20 minutes or after 5 hours) reception stops - the counter stops incrementing, that is, the input to the USB reception interrupt does not occur.

Dear Gurus, maybe you have come across something similar.

I really hope for your help!

Thanks!

3 REPLIES 3
ISely.1
Associate II

It's all right. solved the problem. Thank you all (no one answered)

Forums can be like that, plus the problem looks to be one where you'd need to be touching the device and code to be debugging it, so unless you and your team​ facilitate that, probably not going to get much traction.

Was it any of the code shown, or something else?​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ISely.1
Associate II

The problem was in receiving data and processing it by a Delphi program. The STM32 H7 microcontroller works without errors. Thanks to the STM team!