cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746 touchgfx and USB don't work

BMich.2
Associate

I am not able to use both USB (CDC or MSC class tested) and touchgfx (GUI) in my device which consist of:

STM32F746, 800x600 touchscreen, external qspi flash for assets, external sdram and other peripherals like spi or i2c. Firmware is based on freertos.

The main problem is that usb communication cannot work in parallel with gui interface, in separate they work properly with other device functionalities. Right now I handle it by switching device to usb or gui mode during startup but it cannot be final solution.

void StartDefaultTask(void const * argument)
{
  /* init code for FATFS */
  MX_FATFS_Init();
 
  /* init code for LIBJPEG */
  MX_LIBJPEG_Init();
 
  /* init code for USB_DEVICE */
  if (device_mode == USB_MODE)
    MX_USB_DEVICE_Init();
 
/* Graphic application */
  if (device_mode == GUI_MODE)
    GRAPHICS_MainTask();
 
  /* USER CODE BEGIN 5 */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END 5 */ 
}

When I try to launch them together the screen freezes and does not respond for the touch, the usb does not initialize on PC. Kernel logs show something like this:

USB 2/3 device descriptor read64, error -110 three times followed by
usb-2/3 device not accepting address 4, error -110
usb-2/3 device not accepting address 5, error -110

I tried to debug USB initialization and the MX_USB_DEVICE_Init() does not go to ErrorHandler().

I use little deprecated toolchain but the device is certified and I need to stick to these tools:

HAL LIB STM32Cube_FW_F7_V1.15.0

- STM32CubeMX v 5.3.0

- SW4STM32 Version: Neon.3 Release (4.6.3), Build id: 20170314-1500

- TouchGFX Designer 4.10.0

- STM32 ST-LINK Utility 4.5.0.0 

but I am open for propositions of upgrade that can solve the problem in 100%.

Do you have any ideas how to launch them together?

3 REPLIES 3
MM..1
Chief II

You must misconfigure something, TouchGFX is app layer and USB is hw layer. Check interrupts priority and LCD clock. try lower...

LYiu.1
Associate

I have the same problem as OP regarding the integration of TouchGFX with USB mass storage class.

They both can work independently i.e. I could create and write into the file on the USB flash drive if TouchGFX task is disabled.

// hard faults occur when writing into the flash drive and  defaultTask & GUI_Task are running
// commenting either of these tasks then testing them individually doesn't lead to hard fault
 
  /* creation of defaultTask */
  defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
 
  /* creation of GUI_Task */
  GUI_TaskHandle = osThreadNew(TouchGFX_Task, NULL, &GUI_Task_attributes);
 

I'm think this could be due to accessing memory error or memory size insufficient , but I'm unsure of how to debug this.

Any experts can help guide how to correctly implement TouchGFX with USB MSC under FreeRTOS CMSIS_V2 ?

FYI, I was suspecting it could be the issue of not using newLib , so I followed the steps from https://www.codeinsideout.com/blog/stm32/free-rtos/reentrant/

to implement Dave Nadler's library into my project. However even switching to this newLib, the hard-fault still persist

I have made a simple TouchGFX project from the Designer which includes the USB host mass storage class for anyone interested to try it out, let me know if you need to test it

Using the following tools & firmware:

STM32CubeIDE V1.9.0

TouchGFX 4.19.0 Designer

STM32Cube FW_F4 V1.27.0

STM32F429I Discovery Board

Update 1:

I'm finally able to get both the TouchGFX and USB mass storage working simultaneously.

My original implementation to write into the USB flash drive is based from https://controllerstech.com/stm32-usb-host-msc/

File_Handling.h & File_Handling.c

Instead of using the implementation from controllerstech,

i followed STM32 USB training - 11.2 USB MSC host labs

from youtube https://www.youtube.com/watch?v=dC0d8CVEPrQ

and I've finally got no hard-faults

RBoud.1
Associate II

Hi Developers,

I have the same issue but with USB host as USB HID.

When I used USB as HID on its own following the example from Controllers Tech youtube video (I couldn't add the link)

and it worked.

When I used the TouchGFX (on its own) example from the Controllers Tech youtube video (I couldn't add the link) and it worked.

When I use touchGFX and USB HID at the same time, the TouchGFX it is a bit itchy, but it does work but the USB HID, it doesn't work.

The MX_TouchGFX_Init() seems returning ok, but I noticed the void USBH_HID_EventCallback(USBH_HandleTypeDef *phost) doesn't get a call back which mean that the USB interrupt somehow is blocked by the touchGFX or the CubeMx.

Any help will be very appreciated as I run out of idea on what to do

I am using:

  • Microcontroller STM32F446RE
  • STM32CubeMX v6.6.0 with STM32CubeF4 Firmware Package V1.27.0 / 11-February-2022
  • TouchGFX Designer 4.18.0
  • Keil MDK V 5.30.

Thank you in advance.