STM32H7/HAL/RTOS/Castom HID USB. The microcontroller freezes when receiving via USB at any time (from 20 minutes to 5 hours).
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!
