2021-07-29 11:41 PM
unplug my CDC USB output cable and
sprintf( string, "%.2f ",myFloat); will crash
plug it back in to the PC and without any comms, it works.
could it be a memory leak if the CDC driver is not handshook ?
anyhow the CUBE didn't allocate enough Stack space.
fixed here: in the stm32L4xx_flash.lds file
.reserved_for_stack (NOLOAD) :
{
. = ALIGN(4);
PROVIDE(__reserved_for_stack_start__ = .);
KEEP(*(.reserved_for_stack))
. = . + 0x100; /* <--- fixed here */
. = ALIGN(4);
PROVIDE(__reserved_for_stack_end__ = .);
} > SRAM
Solved! Go to Solution.
2021-08-05 08:31 AM
Hello @Community member ,
You're correct about the increase of stack. (s)printf (according to implementation) uses more stack if it processes more complex data (like floats for example). So, it is totally normal to have to increase the stack if it isn't already enough.
Are you using an OS, where the sprintf is located (interrupt, normal code, OS task, etc...)?
BeST Regards,
Walid
2021-08-05 08:31 AM
Hello @Community member ,
You're correct about the increase of stack. (s)printf (according to implementation) uses more stack if it processes more complex data (like floats for example). So, it is totally normal to have to increase the stack if it isn't already enough.
Are you using an OS, where the sprintf is located (interrupt, normal code, OS task, etc...)?
BeST Regards,
Walid
2021-08-10 06:57 PM
Hello Walid,
I use my own OS and never print in the background..
It was my fault in the end.
I changed the Stack and Heap in the Cube down to 0x800 each, to save RAM, but its not ok.
putting it back to 0x1000 for both fixed the issue.
BeST
Nick
2021-08-11 01:08 AM
Good news. Glad to help you.