cancel
Showing results for 
Search instead for 
Did you mean: 

White screen after checking "Generate peripheral initialization as a pair of '.c/.h' files per peripheral" in CubeMX

GHeller
Associate III

I have an issue with TouchGFX on H750B-DK board.

After I create a sample project in TouchGFX and import it into CubeIDE, I can then flash it to my board with no issues. But the project generated by TouchGFX is very messy (everything put into main.c), so I would like to check the below option in CubeMX:

0693W00000GZ6sSQAT.pngBut with this option enabled the project suddenly stops working (TouchGFX task doesn't enter the infinite for loop). Also, after I uncheck it and flash it again, it still doesn't work, which is interesting because in this state the project should be the same as at the beginning, which worked.

I debugged it and found out that the function backPorchExited() never returns. I can go as far as HAL::endFrame() in TouchGFXGeneratedHAL.cpp, but when I step into this function the debugger hangs (enters a state as if I pressed run with no breakpoints). When I pause it, I find myself in portTASK_FUNCTION() in tasks.c, running vApplicationIdleHook() perpetually. Concurrently the second task, which is created automatically by TouchGFX, enters infinite for loop without issues (it's an empty task though).

Could anyone please help me with this?

1 ACCEPTED SOLUTION

Accepted Solutions
Michael K
Senior III

It's because checking that box wipes out all the user code, including the code supplied by the application template used for initializing SDRAM, QSPI, etc.

It's a bug in CubeIDE / CubeMX - basically instead of copying the generated code blocks with the user code, it deletes the code from main and regenerates it fresh in the c/h files.

Here's how I solved it: First backup your main.c file before checking that button. Check the box and regenerate. Then go through the backup main.c and cross check EVERY user code section with the user code sections in the new c/h files. Copy the code from the backup in to the corresponding user code sections in the C/H files.

It's a pain in the ***, but it's worth it to not have a mega-main, lol.

Note as well, CubeIDE has a glitch (at least on my system) where it automatically unchecks that box every time you open the device configurator, so you need to check it every time.

Further discussion: https://community.st.com/s/feed/0D50X0000C5VXG1SQO

Embedded UI/UX Consulting: cadenza.design

View solution in original post

3 REPLIES 3
Michael K
Senior III

It's because checking that box wipes out all the user code, including the code supplied by the application template used for initializing SDRAM, QSPI, etc.

It's a bug in CubeIDE / CubeMX - basically instead of copying the generated code blocks with the user code, it deletes the code from main and regenerates it fresh in the c/h files.

Here's how I solved it: First backup your main.c file before checking that button. Check the box and regenerate. Then go through the backup main.c and cross check EVERY user code section with the user code sections in the new c/h files. Copy the code from the backup in to the corresponding user code sections in the C/H files.

It's a pain in the ***, but it's worth it to not have a mega-main, lol.

Note as well, CubeIDE has a glitch (at least on my system) where it automatically unchecks that box every time you open the device configurator, so you need to check it every time.

Further discussion: https://community.st.com/s/feed/0D50X0000C5VXG1SQO

Embedded UI/UX Consulting: cadenza.design

Thank you for this reply and I am glad that the ST are aware of this, even though I think by now this should have been fixed already. It is indeed a pain...

MKova.3
Associate II

To resolve this issue:

1. Take the main file before changing

2. Find all the code that is between the notes USER CODE BEGIN and USER CODE END

3. Copy and Paste this code in the same places in the newly created files

that's it