2017-01-20 08:05 AM
Hi
I used STM32CubeMX and configured a project using RTOS and USB_DEVICE (I am trying to run the USB CDC functionality with the FreeRTOS). The program runs until it hits the USB_CoreInit function inside stm32f4xx_hal_pcd.c file and then something bizarre occurs, it hangs and when i hit pause in EWARM the program counter is somewhere random. If i comment out the function the RTOS runs fine but obviously then the USB still doesn't work.
Has anyone had a similar issue?
Thanks
Ryan
2017-01-20 08:58 AM
Hi
stephen.ryan
,Try to increase heap and stack sizes. Then, please let me know if it is OK with this suggestion.
-Nesrine-
2017-01-23 01:33 AM
Hi
ELMHIRI.Syrine
Thank you for your reply,
Is there an option for increasing these in cubeMX? I have tried increasing the stack size for the RTOS task allocated to USB and have also increased the heap and stack size within the linker configuration. I notice that whenever I rebuild the cubeMX project it returns the heap and stack size back to their default value. Is there a minimum heap size for the USB?
Many thanks
Ryan
2017-01-23 03:19 AM
As it turns out it determined the issue was to do with enabling low power mode. I disabled that and it is now working. But it does jump to the vApplicationStackOverflowHook function. Which should I increase? the stack for the RTOS or increase the linker stack information?
Many thanks
2017-01-23 03:43 AM
Hi
Stephen.Ryan
,Is there an option for increasing these in cubeMX?
Is there a minimum heap size for the USB?
maybe you can refer to USB example under the STM32CUBE F4 package : STM32Cube_FW_F4_V1.0\Projects\STM32469I_EVAL\Applications\USB_Device-Nesrine-
Stephen.Ryan wrote:
Hi
ELMHIRI.Syrine
Thank you for your reply,
Is there an option for increasing these in cubeMX? I have tried increasing the stack size for the RTOS task allocated to USB and have also increased the heap and stack size within the linker configuration. I notice that whenever I rebuild the cubeMX project it returns the heap and stack size back to their default value. Is there a minimum heap size for the USB?
Many thanks
Ryan
2017-01-23 03:44 AM
A little further investigation shows that it actually isnt hanging, Looking in the call stack I can see that an interrupt handler 'OTG_FS_WKUP_IRQHandler' is invoked whilst in USB_CoreInit, it also shows '<Exception frame>' but when it is in the interrupt handler it tries to call the SystemClock_Config() again which is what is hanging on line: ' if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)'
2017-01-24 03:19 AM
Thank you for your help
ELMHIRI.Syrine
, i increased the stack and heap sizes further and the device operates without a driver failed to start error which i was seeing before. The low power mode of the USB seem'd to crash the program, out of interest how would one implement the low power mode? is there a function which should invoke a power up/ low power mode enable?