2020-07-28 02:24 AM
Hi,
I am currently trying to develop the Audio device on STM32F0 to stream audio data from USB to IS2 signal, although It worked without any issues on STM32F4 discovery board, when I am trying to apply same logic for Nucleo32 It does not seem to work at all. Windows displays the board like so:
I will try to describe my problem in more details; after successful compilation, while debugging, program stops on HardFault_Handler(); . Code part that seems to be error cause is in usbd_audio.c file in Middlewares section of the project.
I tried to add more heap memory to solve this issue but changing it in the project does not seem to affect STM32F042K6TX_FLASH.ld and when I change it manually it gives an compilation error.
The code is generated through STM32CubeMX, I have not done anything to it. Still I will attach them if someone would like to look through it.
Am I on good track? Did anyone had that issue before? Please share your thoughts.
Solved! Go to Solution.
2020-07-29 09:30 AM
Can't have a 15KB buffer in a 6KB part, reevaluate
2020-07-28 05:05 AM
STM32CubeIDE has a view named hard fault analyzer. when you are in debug mode and hard fault happened, see that view. It has some information about source of failure. take snapshots of it and post here
2020-07-28 06:05 AM
Thank you for the answer! I actually used it to find the code i highlighted on this picture
2020-07-28 08:02 AM
Does the project include RTOS? Increasing heap memory in cubemx does not affect freeRTOS heap size. Also be aware that freeRTOS use special malloc function that is thread safe. wrap your malloc to freeRTOS malloc
2020-07-28 08:35 AM
Yeah, but what assembler code and register values does it hard fault with?
What's failing here? The malloc, the pdev structure, the haudio structure?
2020-07-29 02:30 AM
No only middleware I use is USB_DEVICE
2020-07-29 02:32 AM
About the assembly code and registers at fault I am linking them right here
2020-07-29 07:20 AM
I think you are using the pointer "haudio" without initialization. It may be a null pointer. put a break point at line 349. when the break point hits, check the pointer value. It must point to an address in your RAM space.
2020-07-29 08:03 AM
Seems like the pointer value is 0, so you are right, although what I did in this project was just generating the files in CubeMx. Any idea how to solve this issue?
2020-07-29 08:59 AM
Simple way is:
USB_AUDIO_HandleTypeDef audio;
haudio = &audio;
Or you can:
USB_AUDIO_HandleTypeDef haudio;
then use dot "." instead of "->" when you want to reference haudio. example:
haudio->offset turns to haudio.offset