AnsweredAssumed Answered

Memory Hard fault with string lib

Question asked by alexandre.dauphi.001 on Sep 2, 2016
Latest reply on Sep 2, 2016 by Clive One

Hi everyone,

I have a question about an hard fault generated by a line of code.
I'm working with a STM32F401RE  and Atollic True Studio

The line is :
sprintf(str, "PAIR %s\r",BT_deviceTAB[0].BDADDR);

the BT_deviceTAB[0].BDADDR type is char tab[13];
and previously filled with a string ended with '\0'

The hardfault is :
Bus, memory management or usage fault (FORCED)
Attempt to switch to invalid state (INVSTATE)

But when i use the following methode i don't have any problems :

strcpy(str,"PAIR ");
strcat(str, name);

Do you have an explanation of how this functions works.
I'm very surprised that sprintf generate memory hard fault Oo !

Thanks a lot