cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CUBEIDE code generation is fantastic (when it works correctly)

FredS
Senior

Hallo all,

I am brand new to this forum and quite new to MCU programming and STM32CUBEIDE (v 1.12.1). After some struggle, lots of reading, trying and retrying, I managed to create a project that runs on my Nucleo-L476RG. I already learned to make limited steps and save a copy of each version (simply making a zip-file of the whole project-directory).For completeness: I work on a DELL PC with 12GB memory, running Windows10-Educational.

My project is not too complicated (to my idea): an ADC channel, triggered by OC4REF of Timer4, samples one voltage source at 250kS/s and is configured to write the results to a data-array by DMA. The data array is defined as 'Normal', so the DMA transfer ends when 'array-len' samples are handled. The ADC is also configured to generate an interrupt for 'HAL_ADC_ConvCpltCallback', which calls 'HAL_ADC_Stop_DMA(&hadc1)', 'CDC_Transmit_FS(....)', and 'HAL_ADC_Start_DMA(^hadc........)' to copy the data-array in memory to the USB port, defined by 'USB_OTG_FS' and start the DMA transfer for the following set of data.

I must admit I retrieved the essential parts of the code from a YouTube movie, created by someone who did about the same I want. And after some trail and error (again), I managed to get a stream of reasonable data from the USB port. But an essential problem remained: detection of the begin and end of a dataset in the stream of bytes at the USB-port. I spent a lot of time on several possible solutions in my last version 3.0 and got a new, unexpected and maybe unrelated problem: the code I have is compiled without complaints, can be uploaded to the MCU, but the USB port is not recognized by my PC any more.
When I dig deeply into the sources I find some source files for the USB_port, marked with error-crosses. When I dig further, I see there are some structures missing, like 'USBD_CDC_HandleTypeDef' and 'USBD_CDC_ItfTypeDef' and members of those structures. The "offending lines" are partially marked with red underlining and a "sign" before the line-nr, see the uploaded screenshot. I also saw a file with many lines with an orange underlining, no idea of the meaning.
The overall suspicion I have is that somewhere in the re-generation of the files for the USB a 'define' is missing or corrupted, ending in a non-coherent set of sources. The result is strange: no compiler errors, but an incomplete functionality. I already tried some obvious repairs: clean the project ad rebuild everything, force the code generation by the 'Device Generation Tool' to re-do, but no result.
This is the dark side of a high level automated toolkit: when is doesn't work as expected it is nearly impossible to crack the problem, unless you are a STM32CUBEIDE guru who does not need such tool at all.

I sincerely hope someone can point out how to solve my problem or how to act to create my project without such errors. It is bizar that my previous v2.1 project did not have any USB issue.

Thanks for your attention,

Fred Schimmel

0 REPLIES 0